关于socket的sendUrgentData 这本来就是一个客户端套接字的方法,不知道你指的在服务器使用是什么意思~里面接收的是int类型参数~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 服务器端是这样的socket = serversocket.accept();然后服务器端每隔一段时间就socket.sendUrgentData(oxff),这个是没问题的可以正确检测客户端的连接状态 但是在客户端的用socket.sendUrgentData(oxff)就会出问题,服务器是一直处理连接状态 的,但是客户端的socket.sendUrgentData(oxff)会报错 http://blog.csdn.net/cclsw07/article/details/6089587 你的客户端的socket的host和port对么? host跟port都是正常的,服务器与客户端完成通信后,就分别隔一段时间检测对方的连接状态,就是在客户端检测服务器端连接状态的时候socket.sendUrgentData(oxff)用这个老是会抛exception,但实际上服务器端一直是处于连接状态的 没人帮忙吗,自己再顶一下我客户端的代码是这样的:boolean testConnection(Socket socket)throws IOException{if(!socket.isConnected)socket.close();return falsetry{System.out.println("send urgentData to server"); socket.sendUrgentData(oxff);}catch(IOException e){System.out.println("send urgent data fault");socket.close();return false;}retrun true;}服务器端是一直保持连接状态的但客户端这边的输出 会是System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgentData to server");System.out.println("send urgent data fault"); JFrame显示图片问题 。。一个自学者的无奈。。在线等待结果。。。 一个SCJP的题麻烦给位来看看 boolean, String,或者bit这些字段怎么转换啊? 请教一个java和sql server连接问题? 关于JBuilder 9的问题 Java中如何读取系统变量的值 文件中各字段通过tab(ASCII 值为09)键分隔,如何解析。 问:为何右边的值无法赋给左边?(高分!) 稚嫩小问题。。。 急求!关于Java的正则表达式问题 【加紧帖】分离有特定标示的字符串并进行处理 讲下Java的入口函数
socket = serversocket.accept();然后服务器端每隔一段时间就socket.sendUrgentData(oxff),这个是没问题的可以正确检测客户端的连接状态
但是在客户端的用socket.sendUrgentData(oxff)就会出问题,服务器是一直处理连接状态 的,但是客户端的socket.sendUrgentData(oxff)会报错
你的客户端的socket的host和port对么?
host跟port都是正常的,服务器与客户端完成通信后,就分别隔一段时间检测对方的连接状态,就是在客户端检测服务器端连接状态的时候socket.sendUrgentData(oxff)用这个老是会抛exception,但实际上服务器端一直是处于连接状态的
我客户端的代码是这样的:
boolean testConnection(Socket socket)throws IOException{
if(!socket.isConnected)
socket.close();
return false
try{
System.out.println("send urgentData to server");
socket.sendUrgentData(oxff);}
catch(IOException e){
System.out.println("send urgent data fault");
socket.close();
return false;
}retrun true;
}服务器端是一直保持连接状态的
但客户端这边的输出 会是
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgentData to server");
System.out.println("send urgent data fault");