title: Sony Xperia Z : SocketTimeoutException Only Sony Xperia Z (4.4.2)
body: <h2><strong><em>This problem happen Only Sony Xperia Z (4.4.2)</em></strong></h2>
  
  <p>I am working one android audio player app. the app read audio form sdcard as a local server.  </p>
  
  <p>I make local server because this audio are Encrypted and big size, so, if i try to run full audio file at a time and decrypt it then i take long time run media player that why i make this local server to read this audio file. </p>
  
  <p><strong>My local server ServerSocket connection code.</strong></p>
  
  <pre><code>int SERVER_PORT=35415;
  socket = new ServerSocket(SERVER_PORT, 0, InetAddress.getByAddress(new byte[]{127,0,0,1}));
  socket.setSoTimeout(5000);
  port = socket.getLocalPort();
  
  Socket client = socket.accept(); /// this line give exception Only Sony Xperia Z (4.4.2).
  </code></pre>
  
  <p><strong>The problem is,</strong> When i try check socket are open to read Audio Steam (<a href="http://developer.android.com/reference/java/net/ServerSocket.html#accept%28%29" rel="nofollow">socket.accept()</a>) then it give <code>SocketTimeoutException</code> every time in Only Sony Xperia Z (4.4.2) not other android phone. </p>
  
  <p><strong>What i have try to solve the problem:::</strong></p>
  
  <ol>
  <li>Increase the socket.setSoTimeout(5000) upto 20000.</li>
  <li>remove the socket.setSoTimeout(5000);  code to solve the problem. </li>
  <li>Change the ServerSocket port form "123420" to "123440".</li>
  </ol>
  
  <p><strong>Exception Log.</strong></p>
  
  <pre><code>08-18 20:18:54.344: E/AudioFileStreamProxy(8594): SocketTimeoutException
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594): java.net.SocketTimeoutException
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:108)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at java.net.ServerSocket.implAccept(ServerSocket.java:203)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at java.net.ServerSocket.accept(ServerSocket.java:128)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at com.magnifo.utility.audio.AudioFileStreamProxy.run(AudioFileStreamProxy.java:98)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at java.lang.Thread.run(Thread.java:841)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594): Caused by: libcore.io.ErrnoException: accept failed: EAGAIN (Try again)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at libcore.io.Posix.accept(Native Method)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at libcore.io.BlockGuardOs.accept(BlockGuardOs.java:55)
  08-18 20:18:54.344: E/AudioFileStreamProxy(8594):   at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:98)
  </code></pre>