public bool Initialize(string strHostIP, short intHostPort, short System_Renamed) { bool returnValue = false; int nError = 0; float timeIN = 0; byte TimeOut = 100; var comm = new Comm(); comm.HostIP = strHostIP; comm.HostPort = intHostPort; comm.swTCP = new SocketWrench(); comm.swTCP.OnConnect += new EventHandler(swTCP_OnConnect); //Comm.Comm.KBComm.swTCP.OnConnect += (sender2,e2)=> swTCP_OnConnect(sender2,e2,ref Comm Comm.KBComm); comm.swTCP.OnDisconnect += new EventHandler(swTCP_OnDisconnect); comm.swTCP.OnError += new SocketWrench.OnErrorEventHandler(swTCP_OnError); comm.swTCP.OnRead += new EventHandler(swTCP_OnRead); OnConnectDelegate = swTCP_OnConnect; comm.swTCP.AutoResolve = false; comm.swTCP.Blocking = false; comm.swTCP.Secure = false; // TODO: Updated call of the socket wrench for the new dll. - Ipsit_33 // Refer: https://sockettools.com/webhelp/dotnet/dotnet/htmlhelp/SocketTools.SocketWrench.Initialize_overload_1.html // var result = Comm.KBComm.swTCP.Initialize("FMKLPMFRIKHBMURI"); var result = comm.swTCP.Initialize("BMKJQDIQHXKJUJGRIKTLOSHHJQFOYO"); nError = Convert.ToInt32(result); if (nError != 1) { returnValue = false; // WriteToLogFile("Failed to initialize SocketWrench control"); return(returnValue); } // TODO: Updated call of the socket wrench for the new dll. - Ipsit_34 if (comm.swTCP.Status == SocketWrench.SocketStatus.statusDisconnect || comm.swTCP.Status == SocketWrench.SocketStatus.statusUnused) { Comm.KBComm = comm; // bool i=Comm.KBComm.swTCP.Connect(Comm.KBComm.HostIP, Comm.KBComm.HostPort, SocketWrench.SocketProtocol.socketStream, TimeOut); if (comm.swTCP.Connect(comm.HostIP, comm.HostPort, SocketWrench.SocketProtocol.socketStream, TimeOut)) { OnConnectDelegate?.Invoke(); nError = 1; } else { nError = 0; } Byte[] b = new Byte[30]; //string readStream = string.Empty; //bool result = Comm.KBComm.swTCP.ReadStream(ref readStream); int a1 = comm.swTCP.Write("abcde"); comm.swTCP.Listen(strHostIP, intHostPort); if (comm.swTCP.IsConnected) { //lock (p.thisLock) { int s = comm.swTCP.Read(b); } if (comm.swTCP.IsReadable == true) { } } //nError = Convert.ToInt32(); returnValue = comm.boolIsConnected; } return(returnValue); }