socket是这样发送心跳的,参考一下,这是我写过的部分代码,专门开一个线程发送心跳
new Thread(new Runnable() {
@Override
public void run() {
while(socket!=null &&!socket.isClosed()){
try {
socket.sendUrgentData(0xFF)
} catch (IOException e) {
e.printStackTrace()
reconnect()
}
try {
Thread.sleep(60000)
} catch (InterruptedException e) {
e.printStackTrace()
}
}
log.info("connection is missing!"+Calendar.getInstance().getTime().getTime())
}
}).start()
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)