Public class CommandClient {
Private static Logger Logger=Logger. GetLogger (CommandClient. Class);
Public static OutputStream outStr=null;
Public static InputStream inStr=null;
Private static Thread tKeep=new Thread (new KeepThread ());
Private static Thread tRecv=new Thread (new RecvThread ());
Public static Socket Socket=null;
Private static Boolean iswait=false;
Private static int heartNum=15;
Private static String error;
Private static String errorTitle;
Private static String errorContent;
Public static String temperature="45";
Public static Boolean isError=false;
//socket state
Public static Boolean isServerClosed=true;
Private static Thread aLink;
Private static int count=0;
Private static int comPort=55000;
Public CommandClient IP (String) {
Try {
ComPort++;
If (comPort & gt; 65535) {
JOptionPane. ShowConfirmDialog (null, MessageResource. GetMessage (" Hint. Port ", Language. The getLocale ()));
return;
}
InetAddress InetAddress=InetAddress. GetByName (is ConfigUtils. Properties. GetProperty (" cIP "));
The socket=new socket (IP, the TCP_ML, inetAddress, comPort);
//socket=new socket ();
//socket. Connect (new InetSocketAddress (IP, the TCP_ML), 1000);
IsServerClosed=false;
If (tKeep isAlive ()==false) {
If (iswait==false) {
TKeep. Start ();
} else {
TKeep=new Thread (new KeepThread ());
TKeep. Start ();
}
}
If (tRecv isAlive ()==false) {
TRecv. Start ();
}
OutStr=socket. GetOutputStream ();
InStr=socket. GetInputStream ();
HeartNum=5;
Count=0;
If (DialogAlert dialogmode!=null) {
DialogAlert. Dialogmode. The dispose ();
}
} the catch (Exception e) {
count++;
Logger. The error (" Device message socket Exception!" + DateUtil. The format (new Date ()));
Logger. The error (e);
IsError=true;
IsServerClosed=true;
The socket=null;
OutStr=null;
InStr=null;
FullDuplexClient. Socket=null;
FullDuplexClient. OutStr=null;
FullDuplexClient. InStr=null;
If (count==1) {
String error=MessageResource. GetMessage (MainFrame. The TabbedPane. "error", Language. The getLocale ())
+ "- Err1007";
String errorTitle=MessageResource. GetMessage (Message. Error7. "Title", Language. The getLocale ());
String errorContent=MessageResource. GetMessage (Message. Error7. "Content", Language. The getLocale ());
DialogAlert. ShowImageLossDialog (new JFrame (), new JFrame (),
"& lt; Html>" + error + errorTitle + "& lt; Br/& gt;" + + "errorContent & lt; Br/& gt;