这本来就是一个客户端套接字的方法,不知道你指的在服务器使用是什么意思~里面接收的是int类型参数~

解决方案 »

  1.   

    服务器端是这样的
    socket = serversocket.accept();然后服务器端每隔一段时间就socket.sendUrgentData(oxff),这个是没问题的可以正确检测客户端的连接状态 
    但是在客户端的用socket.sendUrgentData(oxff)就会出问题,服务器是一直处理连接状态 的,但是客户端的socket.sendUrgentData(oxff)会报错
      

  2.   

    http://blog.csdn.net/cclsw07/article/details/6089587
      

  3.   


    你的客户端的socket的host和port对么?
      

  4.   


    host跟port都是正常的,服务器与客户端完成通信后,就分别隔一段时间检测对方的连接状态,就是在客户端检测服务器端连接状态的时候socket.sendUrgentData(oxff)用这个老是会抛exception,但实际上服务器端一直是处于连接状态的
      

  5.   

    没人帮忙吗,自己再顶一下
    我客户端的代码是这样的:
    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");