Code Painters The Art of Coding

17Feb/120

Why java.nio is a better idea for Android

In my recent Android project I've encountered totally unexpected, low-level problems with TCP sockets. The problem occurs when you try to interrupt a blocking socket I/O by closing the socket. It is expected for the blocked operation to throw a SocketError exception immediately when the socket is closed from another thread (that's the only way to interrupt blocking socket operation, actually - Thread.interrupt() doesn't abort blocked I/O). Continue reading…