SocketTimeoutException
https://stackoverflow.com/questions/5632279/how-to-set-timeout-on-client-socket-connection 참고
아래 소스가 완벽하게 설명해줌.
socket.connect 는 connection 을 설립(?) 하는데 드는 시간이 초과될 경우 발생하는거고.
socket.setSoTimeout 은 connection 은 성공적으로 연결됐는데 Server 에 있는 데이터 read 하다 시간 초과난 경우
Socket socket = new Socket();
// This limits the time allowed to establish a connection in the case
// that the connection is refused or server doesn't exist.
socket.connect(new InetSocketAddress(host, port), timeout);
// This stops the request from dragging on after connection succeeds.
socket.setSoTimeout(timeout);
'Language > 자바' 카테고리의 다른 글
IO VS NIO (0) | 2017.09.22 |
---|---|
ProtocolBuffer 예제 (0) | 2017.06.22 |
Subject (doAs) (0) | 2017.06.21 |
Exception 참고 (0) | 2017.06.16 |
JMX (0) | 2017.06.14 |