socket exception socket not connected android
<p>Hello 
In my android application i am trying to run a application using GPRS connection and not WIFI.
When tried to run in wifi the app runs fine.
The browser works fine with the APN settings set but when trying to connect to server using my application it gives me socket exception.</p>

<p>I am using the below permissions in manifest file.</p>

<pre><code>&lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"&gt;&lt;/uses- permission&gt;
&lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name= "android.permission.CHANGE_NETWORK_STATE"&gt;&lt;/uses-permission&gt;
 &lt;uses-permission android:name= "android.permission.WRITE_APN_SETTINGS" &gt;&lt;/uses-permission&gt;
 &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" &gt;&lt;/uses-permission&gt;
</code></pre>

<p>I am receiving Socket not connected exception.
Is there any other permission which i need to add for using GPRS connection other than WIFI.</p>

<p>Log details</p>

<blockquote>
  <p>10-27 18:26:19.689: WARN/CalSyncSvc(166): com.motorola.blur.service.email.protocol.activesync.ASException: Problem executing HTTP POST
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendRequest(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommandNoProvisoning(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommand0(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendXMLCommand(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ActiveSyncMgr.sendFolderSyncCommand(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.sendFolderSync(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.updateMapFromFolderSync(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.service.email.protocol.activesync.ProviderAPI.updateFromFolderSync(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.calendar.sync.activesync.SyncService.syncAccount(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.calendar.sync.activesync.SyncService$QueueEntry.run(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:416)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.util.concurrent.FutureTask.run(FutureTask.java:122)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.lang.Thread.run(Thread.java:1058)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at com.motorola.blur.util.concurrent.BlurThreadFactory$BlurPooledThread.run(Unknown Source)
  10-27 18:26:19.689: WARN/CalSyncSvc(166): Caused by: java.net.SocketTimeoutException: Socket is not connected
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket(OSNetworkSystem.java:140)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:229)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:521)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at java.net.Socket.connect(Socket.java:1019)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:317)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:129)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
  10-27 18:26:19.689: WARN/CalSyncSvc(166):     ... 17 more
  Please let me know your valuable suggestions.</p>
</blockquote>

<p>Thanks in advance :)</p>
