Socket isConnected() isConnected public boolean isConnected()Returns the connection state of the socket. Returns: true if the socket successfuly connected to a server Since: 1.4 好像if((sock==null)||(sock.isConnected()))不对劲吧
isClosed public boolean isClosed() Returns the closed state of the socket. Returns: true if the socket has been closed Since: 1.4 See Also: close() 不过是1.4才有的方法
isConnected
public boolean isConnected()Returns the connection state of the socket. Returns:
true if the socket successfuly connected to a server
Since:
1.4
好像if((sock==null)||(sock.isConnected()))不对劲吧
比如
sco unix 如果你telnet连接到sco unix,然后禁用网卡,sco unix不能判断telnet页断开而退出连接。这是系统bug。我用c/c++ for sock 测试过,无法判断是否连接。
winNT,c/c++可以判断,系统会报错。
java 我没有试过,不好意思:)
谁有更绝点的,多谢多谢。
如果这不能解决的话,程序就太不健壮了
boolean socket.getKeepAlive().
多谢
public boolean isClosed()
Returns the closed state of the socket. Returns:
true if the socket has been closed
Since:
1.4
See Also:
close()
不过是1.4才有的方法
这样就没有显式调用close(),这样的话,还能够监测到这个socket的死活么?
我反正是试了一下,isClosed()不好用。
救命啊
如此了。不管怎么样,结贴!!!!!!!!!!