0

This problem happen Only Sony Xperia Z (4.4.2)

I am working one android audio player app. the app read audio form sdcard as a local server.

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.

My local server ServerSocket connection 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).

The problem is, When i try check socket are open to read Audio Steam (socket.accept()) then it give SocketTimeoutException every time in Only Sony Xperia Z (4.4.2) not other android phone.

What i have try to solve the problem:::

  1. Increase the socket.setSoTimeout(5000) upto 20000.
  2. remove the socket.setSoTimeout(5000); code to solve the problem.
  3. Change the ServerSocket port form "123420" to "123440".

Exception Log.

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)
Md Abdul Gafur
  • 6,213
  • 2
  • 27
  • 37
  • 1
    I don't know about you, but [this `SocketServer` reference](http://developer.android.com/reference/java/net/ServerSocket.html) tells me that the first argument to the `ServerSocket` constructor should be an *integer* and not a string. And as it's a port number, it should be in the range of `0` to `65535` (inclusive). – Some programmer dude Aug 19 '14 at 10:16
  • @Joachim Pileborg . I am edit my question, Please check it. – Md Abdul Gafur Aug 19 '14 at 10:20
  • You listed 3 workarounds above to solve the problem. What's the reason you can't use those as a solution? – mldeveloper Aug 25 '14 at 21:52
  • I am try listed 3 workarounds above to solve the but the problem is not solve by this three 3 workarounds. It still gives SocketTimeoutException. – Md Abdul Gafur Aug 26 '14 at 03:55

0 Answers0