Esempio n. 1
0
 public void Run()
 {
     int inBufferCount;
     try
     {
         serialPort = Comm2IP.GetSerialPort(socket, comPort, baudRate);
         while (true)
         {
             inBufferCount = socket.Receive(inBuffer);
             if (inBufferCount == 0) break;
             serialPort.Send(inBuffer, inBufferCount);
         }
     }
     catch (Exception e)
     {
         log.Error(e);
     }
     finally
     {
         log.Info("Lost connection from: " + socket.RemoteEndPoint + " for: " + comPort + "@" + baudRate);
         Comm2IP.CloseSerialPort(serialPort);
         try { socket.Close(); }
         catch { }
     }
 }
Esempio n. 2
0
        public void Run()
        {
            int inBufferCount;

            try
            {
                serialPort = Comm2IP.GetSerialPort(socket, comPort, baudRate);
                while (true)
                {
                    inBufferCount = socket.Receive(inBuffer);
                    if (inBufferCount == 0)
                    {
                        break;
                    }
                    serialPort.Send(inBuffer, inBufferCount);
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            finally
            {
                log.Info("Lost connection from: " + socket.RemoteEndPoint + " for: " + comPort + "@" + baudRate);
                Comm2IP.CloseSerialPort(serialPort);
                try { socket.Close(); }
                catch { }
            }
        }