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
请问各位大侠问题出在哪里?谢谢!