Re: [問題] 新手問socket

看板java作者 (shooting star)時間17年前 (2007/03/16 17:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《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
文章代碼(AID): #15-cYD5o (java)
討論串 (同標題文章)
文章代碼(AID): #15-cYD5o (java)