Skip to content

Java.net.Socket

Java 소켓(Socket)통신과 관련된 정리.

How to terminate a thread blocking on socket IO operation instantly

There are two ways to do this:

  • Calling Thread.interrupt() will (under some circumstances that are not specified) interrupt a blocking I/O operation, causing it to throw an InterruptedIOException or ClosedByInterruptException.
  • Calling Socket.close() on the socket will close the associated InputStream and OutputStream objects, and cause any threads blocked in Socket or (associated) stream operations to be unblocked. According to the javadoc, operations on the socket itself will throw a SocketException.

See also

Favorite site

References


  1. Java_socket_programming_example.pdf 

  2. Zerioh_tripod_com-Java_Sockets_Example.zip 

  3. Www.javacool.net.zip (www.javacool.net/_cool/api_doc/kor_jdk11api/java.net.Socket_dsc.htm 참조) 

  4. Java_socket_timeout.pdf 

  5. Xrath_com-java-spec.zip (xrath.com/javase/ko/6/docs/ko/api/java/net/Socket.html 참조) 

  6. Java_stream_and_socket.pdf