你server端(192.168.0.156)开8886端口了吗?

解决方案 »

  1.   

    我是把这个语句放在try里啊,我的server端已经开了8886端口了,不知道为什么?
      

  2.   

    你开个dos窗口,输入telnet 192.168.0.156 8886看看是否真的开了
      

  3.   

    import java.io.*;
    import java.net.*;
    import java.util.Random;public class ReceivePingResponse{  private static int DEFAULT_PORT = 100;
      private InetAddress m_target;
      public int test;
      public String isPingable = null;
      public StringBuffer revline;
      public ServerSocket ss;  public void ReceivePingResponse(){
        try{
          ss = new ServerSocket(DEFAULT_PORT,3);
        }catch(Exception e){
          e.printStackTrace();
        }
      }
      public void run(){
        try{
          while(true){
            Socket client = ss.accept();
          }
        }catch(Exception e){
        }}
       public static void main(String[] args){
          ReceivePingResponse rpr = new ReceivePingResponse(); 
      rpr.run();
       }
    }
    我的程序是这样,为什么执行后没有打开端口呢?
      

  4.   

    你的DEFAULT_PORT值不是100吗?你是想打开100端口吗?应该是你说的8886才对呀?