Esempio n. 1
0
        public void InitServer()
        {
            Close();
            _sock.ConnectionInfoString = String.Format("MODE=TCP_PASSIVE, PORT={0}, KEEP_ALIVE=1", _port);
            _sock.Open();

            //heartbeatTimer.Start();
        }
Esempio n. 2
0
        public void InitServer()
        {
            receiveSock.Close();
            System.Threading.Thread.Sleep(100);
            receiveSock.ConnectionInfoString = String.Format("MODE=TCP_PASSIVE, PORT={0}", receivePort);
            receiveSock.Open();

            SendSock.Close();
            System.Threading.Thread.Sleep(100);
            SendSock.ConnectionInfoString = String.Format("MODE=TCP_PASSIVE, PORT={0}", sendPort);
            SendSock.Open();
        }
Esempio n. 3
0
        public void SocketConnected(string module, int socketCount, string IP, int Port, bool isActive)
        {
            if (String.IsNullOrEmpty(IP))
            {
                return;
            }

            int iPort = Port;

            sock_dic = new Dictionary <string, CSerialDriver>();

            EqpId = module;

            for (int i = 1; i <= socketCount; i++)
            {
                CSerialDriver serialDrv = new CSerialDriver();
                serialDrv.Name = module + "_" + iPort.ToString();
                serialDrv.ConnectionStateChanged += Sock_ConnectionStateChanged;
                serialDrv.OnReceivedBytes        += Recv_sock_OnReceivedBytes;
                if (isActive)
                {
                    serialDrv.ConnectionInfoString = string.Format("MODE=TCP_ACTIVE, IP={0}, PORT={1}, KEEP_ALIVE=1", IP, iPort);
                    serialDrv.ActiveOpen();
                }
                else
                {
                    serialDrv.ConnectionInfoString = string.Format("MODE=TCP_PASSIVE, PORT={0}, KEEP_ALIVE=1", iPort);
                    serialDrv.Open();
                }
                serialDrv.EnableLog(false, false);
                sock_dic.Add(serialDrv.Name, serialDrv);
                iPort++;
            }

            _byteModule = new byte[EqpId.Length];

            for (int i = 0; i < EqpId.Length; i++)
            {
                _byteModule[i] = Convert.ToByte(EqpId[i]);
            }
        }