android - "IOException: Try again" while using LocalServerSocket -
does have more helpful information on exception "try again"?
i'm sending bitmaps between apps using localserversocket
, 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 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): @ android.net.localsocketimpl.readba_native(native method) 04-18 09:19:11.664: w/system.err(1268): @ android.net.localsocketimpl.access$400(localsocketimpl.java:29) 04-18 09:19:11.664: w/system.err(1268): @ android.net.localsocketimpl$socketinputstream.read(localsocketimpl.java:92) 04-18 09:19:11.664: w/system.err(1268): @ libcore.io.streams.readfully(streams.java:81) 04-18 09:19:11.664: w/system.err(1268): @ java.io.datainputstream.readint(datainputstream.java:124) 04-18 09:19:11.664: w/system.err(1268): @ com.test.util.bitmapsendingutils$bitmapreceiver$1.run(bitmapsendingutils.java:105)
the exception see java equivalent eagain error. see example this answer.
you should handle exception , try failed io operation again.
Comments
Post a Comment