日期:2014-05-20  浏览次数:20754 次

请大家帮我看看这段程序的问题
import   java.io.*;
import   java.net.*;

public   class   CallLink
{
        //使用套接字进行连接
    String   ipAddr=null;        
    Socket   outSock=null;      
    ServerSocket   inServSock=null;      
    Socket   inSock=null;      
    int   TALK_PORT=2007;
    CallLink(String   inIP)
    {      
          ipAddr=inIP;
    }      
    void   open()   throws   IOException,UnknownHostException      
    {//打开网路连接      
      if(ipAddr!=null)      
      outSock=new   Socket(ipAddr,TALK_PORT);      
      }      
    void   listen()   throws   IOException      
      {//监听,等候呼叫
        inServSock=new   ServerSocket(TALK_PORT);      
        inSock=inServSock.accept();      
      }
      public   InputStream   getInputStream()throws   IOException      
      {//返回音频数据输入流      
        if(inSock!=null)      
        return   inSock.getInputStream();      
        else      
        return   null;      
        }
      public   OutputStream   getOutputStream()throws   IOException      
      {//返回音频数据输出流      
        if(outSock!=null)      
        return   outSock.getOutputStream();      
        else      
        return   null;      
      }
      void   close()   throws   IOException      
      {//关闭网络连接      
        inSock.close();      
        outSock.close();      
      }
}


在建立这个类的对象后,调用open()   方法和   listen()方法均抛出异常,小妹初学,实在看不出问题出在哪里,请各位大虾指教!:)

------解决方案--------------------
捕获异常,查看异常信息,见意在调试时不要抛出异常
------解决方案--------------------
服务端没有接收到连接请求,accept方法使线程阻塞