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:::
- Increase the socket.setSoTimeout(5000) upto 20000.
- remove the socket.setSoTimeout(5000); code to solve the problem.
- 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)