I have an applet that connects to a C/C++ server.
The server sends packets but the applet can't read them for some reason.
It gets stuck on socketChannel.read(); even though I set it to non-blocking.
try { socketChannel = SocketChannel.open(); socketChannel.configureBlocking(false); socketChannel.connect(new InetSocketAddress(serverAddress, serverPort)); } catch (UnknownHostException e) { message = "Don't know about host: " + serverAddress; return; } catch (IOException e) { message = "Couldn't get I/O for the connection to: " + serverAddress; return; } try { while(!socketChannel.finishConnect()); } catch(IOException e) { message = "Error on finishConnect();"; return; } try { socketChannel.socket().setTcpNoDelay(true); } catch(SocketException e) { message = "Error: " + e.toString(); return; } message = "Logging in..."; int bytes; try { response.clear(); bytes = socketChannel.read(response); // <------- here } catch (IOException e) { message = "Exception: " + e.getMessage(); return; } message = "Done";