📄 sendthread.java
字号:
so = new Socket(host, port);
out = new DataOutputStream(so.getOutputStream());
input = new DataInputStream(so.getInputStream());
break MISSING_BLOCK_LABEL_2038;
s;
bindFailed = true;
SGIPLog.WriteLog(-2, "Socket Error: " + s.toString(), logFile);
System.out.println("Socket Error: " + s.toString());
if(stateArea != null)
stateArea.append(CTime.getStringDate() + " SGIP12模块客户端初始化失败!\n\n");
bindTimes = 0;
Thread.sleep(1000L);
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
continue; /* Loop/switch isn't completed */
sgip = new SGIP_Command();
if(stateArea != null && bindTimes == 1)
stateArea.append(CTime.getStringDate() + " SGIP12模块客户端初始化成功.\n\n");
System.out.println("--Bind--");
command = new Bind(SPNum, 1, loginName, loginPwd);
int err = command.write(out);
if(packetArea != null)
{
packetArea.append(CTime.getStringDate() + "--SGIP12--Bind: (SP->SMG)\n");
packetArea.append("TotalLength: " + command.getTotalLength() + "\n");
packetArea.append("CommandID: " + command.getCommandID() + "\n");
packetArea.append("SequenceID_1: " + command.getSeqno_1() + "\n");
packetArea.append("SequenceID_2: " + command.getSeqno_2() + "\n");
packetArea.append("SequenceID_3: " + command.getSeqno_3() + "\n");
packetArea.append("LoginType: " + command.GetLoginType() + "\n");
packetArea.append("LoginName: " + command.GetLoginName() + "\n");
packetArea.append("LoginPassword: " + command.GetLoginPassword() + "\n\n");
}
if(err != 0)
{
bindFailed = true;
SGIPLog.WriteLog(-2, err + " 发送Bind出错", logFile);
System.out.println("err: " + err + " 发送Bind出错");
throw new Exception("err: " + err + " 发送Bind出错");
}
SGIP_Command tmp = sgip.read(input);
if(sgip.getCommandID() == 0x80000001)
{
BindResp resp = (BindResp)tmp;
resp.readbody();
System.out.println(tmp.getSeqno_1());
System.out.println(tmp.getSeqno_2());
System.out.println(tmp.getSeqno_3());
System.out.println(resp.GetResult());
if(packetArea != null)
{
packetArea.append(CTime.getStringDate() + "--SGIP12--BindResp: (SMG->SP)\n");
packetArea.append("TotalLength: " + resp.getTotalLength() + "\n");
packetArea.append("CommandID: " + resp.getCommandID() + "\n");
packetArea.append("SequenceID_1: " + resp.getSeqno_1() + "\n");
packetArea.append("SequenceID_2: " + resp.getSeqno_2() + "\n");
packetArea.append("SequenceID_3: " + resp.getSeqno_3() + "\n");
packetArea.append("Result: " + resp.GetResult() + "\n\n");
}
int bindResult = resp.GetResult();
if(bindResult != 0)
bindFailed = true;
switch(bindResult)
{
case 1: // '\001'
SGIPLog.WriteLog(-2, "Bind包:非法登录,如登录名、口令出错、登录名与口令不符等", logFile);
break;
case 2: // '\002'
SGIPLog.WriteLog(-2, "Bind包:重复登录,如在同一TCP/IP连接中连续两次以上请求登录", logFile);
break;
case 3: // '\003'
SGIPLog.WriteLog(-2, "Bind包:连接过多,指单个节点要求同时建立的连接数过多", logFile);
break;
case 4: // '\004'
SGIPLog.WriteLog(-2, "Bind包:登录类型错,指bind命令中的logintype字段出错", logFile);
break;
case 5: // '\005'
SGIPLog.WriteLog(-2, "Bind包:参数格式错,指命令中参数值与参数类型不符或与协议规定的范围不符", logFile);
break;
case 9: // '\t'
SGIPLog.WriteLog(-2, "Submit包:非法序列号,包括序列号重复、序列号格式错误等", logFile);
break;
case 6: // '\006'
case 7: // '\007'
case 8: // '\b'
default:
SGIPLog.WriteLog(-3, "Bind包:未知错误!", logFile);
break;
case 0: // '\0'
break;
}
break MISSING_BLOCK_LABEL_3147;
}
bindFailed = true;
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
continue; /* Loop/switch isn't completed */
int xx;
int nn;
int Wsize = slideWindow.getFreeWindowSize();
int Qsize = sendQueue.size();
xx = Wsize >= Qsize ? Qsize : Wsize;
nn = 0;
goto _L2
_L5:
SGIPPacket pkt = new SGIPPacket();
pkt = sendQueue.DeQueue();
slideWindowData = new SlideWindowData(pkt);
slideWindow.enSlideWindow(slideWindowData);
slideWindow.sendPacket(input, out);
goto _L3
Exception e;
e;
SGIPLog.WriteLog(-2, "slideWindow Send: " + e.toString(), logFile);
System.out.println("slideWindow Send: " + e.toString());
break; /* Loop/switch isn't completed */
_L3:
nn++;
_L2:
if(nn < xx) goto _L5; else goto _L4
_L4:
System.out.println("--Unbind--");
term = new Unbind(SPNum);
int err = term.write(out);
if(packetArea != null)
{
packetArea.append(CTime.getStringDate() + "--SGIP12--Unbind: (SP->SMG)\n");
packetArea.append("TotalLength: " + term.getTotalLength() + "\n");
packetArea.append("CommandID: " + term.getCommandID() + "\n");
packetArea.append("SequenceID_1: " + term.getSeqno_1() + "\n");
packetArea.append("SequenceID_2: " + term.getSeqno_2() + "\n");
packetArea.append("SequenceID_3: " + term.getSeqno_3() + "\n\n");
}
if(err != 0)
{
SGIPLog.WriteLog(-2, err + " 发送Unbind出错", logFile);
System.out.println("err: " + err + " 发送Unbind出错");
throw new Exception("err: " + err + " 发送Unbind出错");
}
SGIP_Command tmp = sgip.read(input);
if(sgip.getCommandID() == 0x80000002)
{
UnbindResp Unresp = (UnbindResp)tmp;
System.out.println(tmp.getSeqno_1());
System.out.println(tmp.getSeqno_2());
System.out.println(tmp.getSeqno_3());
if(packetArea != null)
{
packetArea.append(CTime.getStringDate() + "--SGIP12--UnbindResp: (SMG->SP)\n");
packetArea.append("TotalLength: " + Unresp.getTotalLength() + "\n");
packetArea.append("CommandID: " + Unresp.getCommandID() + "\n");
packetArea.append("SequenceID_1: " + Unresp.getSeqno_1() + "\n");
packetArea.append("SequenceID_2: " + Unresp.getSeqno_2() + "\n");
packetArea.append("SequenceID_3: " + Unresp.getSeqno_3() + "\n\n");
}
out.close();
}
slideWindow.increWaitedTime(1);
Thread.sleep(1000L);
so.close();
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
break MISSING_BLOCK_LABEL_4484;
SGIP_Exception e;
e;
SGIPLog.WriteLog(-1, "Send: " + e.toString(), logFile);
System.out.println("Send: " + e.toString());
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
break MISSING_BLOCK_LABEL_4484;
SocketException se;
se;
SGIPLog.WriteLog(-2, "SendThread Socket: " + se.toString(), logFile);
System.out.println("SendThread Socket: " + se.toString());
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
break MISSING_BLOCK_LABEL_4484;
Exception e;
e;
SGIPLog.WriteLog(-1, "Send: " + e.toString(), logFile);
System.out.println("Send: " + e.toString());
e.printStackTrace();
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
break MISSING_BLOCK_LABEL_4484;
Exception exception;
exception;
try
{
Thread.sleep(10L);
if(so != null)
so.close();
}
catch(Exception s)
{
SGIPLog.WriteLog(-2, s.toString(), logFile);
System.out.println(s.toString());
}
throw exception;
_L1:
if(running || sendQueue.size() > 0) goto _L7; else goto _L6
_L6:
if(stateArea != null)
stateArea.append(CTime.getStringDate() + " SGIP12模块客户端已经退出!\n\n");
destroy = 2;
return;
}
public void setDestroy(int desty)
{
destroy = desty;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -