Does anybody have more helpful information on the Exception "Try again"?
I'm sending Bitmaps between apps using LocalServerSocket
and LocalSocket
:
Output:
socket = new LocalSocket();
socket.connect(new LocalSocketAddress(SOCKET_NAME));
fos = new DataOutputStream(socket.getOutputStream());
...
public void onEvent() {
fos.writeInt(width);
fos.writeInt(height);
fos.writeInt(newBuffer.length);
fos.write(newBuffer);
}
Input:
server = new LocalServerSocket(SOCKET_NAME);
socket = server.accept();
socket.setSoTimeout(60);
while(true) {
int width = fis.readInt(); // IO Exception being thrown here
int height = fis.readInt();
int length = fis.readInt();
byte[] bytes = new byte[length];
fis.read(bytes);
}
[try/catch etc removed for clarity]
04-18 09:19:11.664: W/System.err(1268): java.io.IOException: Try again
04-18 09:19:11.664: W/System.err(1268): at android.net.LocalSocketImpl.readba_native(Native Method)
04-18 09:19:11.664: W/System.err(1268): at android.net.LocalSocketImpl.access$400(LocalSocketImpl.java:29)
04-18 09:19:11.664: W/System.err(1268): at android.net.LocalSocketImpl$SocketInputStream.read(LocalSocketImpl.java:92)
04-18 09:19:11.664: W/System.err(1268): at libcore.io.Streams.readFully(Streams.java:81)
04-18 09:19:11.664: W/System.err(1268): at java.io.DataInputStream.readInt(DataInputStream.java:124)
04-18 09:19:11.664: W/System.err(1268): at com.test.util.BitmapSendingUtils$BitmapReceiver$1.run(BitmapSendingUtils.java:105)
The exception you see is probably the java equivalent to the EAGAIN error. See for example this answer.
You should handle the exception and try the failed IO operation again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With