首页 新闻 会员 周边 捐助

接收联通MO短信时一直抛出connection Reset异常

0
悬赏园豆:20 [已关闭问题]

public class ReceiveSMS implements Runnable
{
 //獲取參數
 ParseXml parse = new ParseXml("ConfigFile"); 
 int port = Integer.parseInt(parse.getPare("LocalPort"));//端口
 int nodeID =Integer.parseInt(parse.getPare("NodeID"));//節點ID
 
 int returnresult = 0;//返回給網關的結果
 
 DisposeSMS dissms = new DisposeSMS();
  
 SGIP_Command command = new SGIP_Command();
 SGIP_Command tempcmd = null;
 
 Bind bind = null;
 Unbind unbind = null;
 
 BindResp bindresp = null;
 UnbindResp unbindresp = null;
 
 Deliver deliver = null;
 DeliverResp deliverresp = null;
 
 Report report = null;
 ReportResp reportresp = null;
 
 Userrpt userrpt = null;
 UserrptResp userrptresp = null;
  
 ServerSocket serverso = null;
 Socket so = null;
  
 public ReceiveSMS()
 {
  
 }
 
 
 public void run()
 {
  int time = 0;
  
  try
  {
   serverso = new ServerSocket(port); 
  }
  catch(Exception e)
  {
   System.out.println("ReceiveSMS Socket Error:" + e.toString());
  }
  
  while(true)
  {
   try
   {
    System.out.println("ReceiveThread time: " + time ++);
    this.waitconnect();
    
   }
   catch(Exception ex)
   {
    ThreadSta.ReceiveSMSThread = false;
    System.out.println(ex.toString());
   }
   try
   {
    Thread.sleep(1000);
   }
   catch(InterruptedException ex)
   {
    ex.printStackTrace();
   }
   
   continue;
  }
 }
  
 
 /**
  * TODO 等待連接,接收從短信閘道發來的短信
  *
  */
 public void waitconnect()
 {

  try
  {
   so = serverso.accept();
   
   OutputStream output = so.getOutputStream();
   InputStream input = so.getInputStream();
      
   boolean loop = true;
   while(loop)
   {
    this.tempcmd = command.read(input);//接收任何來自網關的命令
    
    switch(command.getCommandID())//獲取命令代碼,看是那種類型命令
    {
     case SGIP_Command.ID_SGIP_BIND :
     {
      this.dealBind(output);
      break;
     }
     case SGIP_Command.ID_SGIP_UNBIND :
     {
      this.dealUnbind(output);
      loop = false;
      break;
     }
     case SGIP_Command.ID_SGIP_DELIVER :
     {
      this.dealDeliver(output);
      break;
     }
     case SGIP_Command.ID_SGIP_REPORT :
     {
      this.dealReport(output);
      break;
     }
     case SGIP_Command.ID_SGIP_USERRPT :
     {
      this.dealUserrpt(output);
      break;
     }
    }
   }
   so.close();
  }
  catch(SocketException e)
  {
   System.out.println(e.toString());
   dissms.createlog("Receive Information Exception.log",e.toString());
  }
  catch(IOException ex)
  {
   dissms.createlog("Receive Information Exception.log",ex.toString());
  }
  catch(Exception x)
  {
   dissms.createlog("Receive Information Exception.log",x.toString());
  }
 }

 

一直抛出这个异常:java.net.SocketException: Connection reset

请问各位大侠问题出在哪里?谢谢!

问题补充: 在这里抛出异常: this.tempcmd = command.read(input);//接收任何來自網關的命令 然后在这里捕捉到异常: catch(SocketException e) {}
谁啊器是的主页 谁啊器是 | 初学一级 | 园豆:180
提问于:2009-11-16 10:00
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册