作者NightPrince (shooting star)
看板java
标题Re: [问题] 新手问socket
时间Fri Mar 16 17:51:08 2007
※ 引述《scdog (just do it)》之铭言:
: 我用java写了一个tcp socket server
: 但是当client自行断线时,server却不知道client已经断线
: 还一直丢封包给client(我程式写成连线成功一直丢封包)
: 不知道socket有没有function能够判断对方已经断线
: 乾瞎!
有的
isConnected method or isClosed method
public boolean isConnected()
Returns the connection state of the socket.
Returns:
true if the socket successfuly connected to a server
Since:
1.4
public boolean isClosed()
Returns the closed state of the socket.
Returns:
true if the socket has been closed
Since:
1.4
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.96.181