public TCPClientConnection(Socket socket, TCPListener myTCPListener, bool useMessageCollector, string ETX)
        {
            try
            {
                fUseMessageCollector = useMessageCollector;
                fIPAddress           = socket.RemoteEndPoint.ToString();
                fConnection          = socket;
                fIsConnected         = true;

                fReadBufferSize = myTCPListener.ReadBufferSize;
                fReadBuffer     = new byte[fReadBufferSize];

                if (myTCPListener.ConnectionTimeOut > 0) //Connection time-out.
                {
                    fConnection.ReceiveTimeout = myTCPListener.ConnectionTimeOut;
                    fConnection.SendTimeout    = myTCPListener.ConnectionTimeOut;
                }
                fConnection.ReceiveBufferSize = myTCPListener.ReadBufferSize;
                fConnection.SendBufferSize    = myTCPListener.ReadBufferSize;

                fMyListener      = myTCPListener;
                fMyExtasysServer = myTCPListener.MyExtasysTCPServer;
            }
            catch (SocketException ex)
            {
                DisconnectMe();
                return;
            }
            catch (Exception ex)
            {
                DisconnectMe();
                return;
            }

            if (fUseMessageCollector)
            {
                fMyMessageCollector = new TCPClientConnectionMessageCollector(this, ETX);
            }

            fMyListener.AddClient(this);
            StartReceivingData();

            fConnectionStartUpDateTime = DateTime.Now;
        }
        public TCPClientConnection(Socket socket, TCPListener myTCPListener, bool useMessageCollector, string ETX)
        {
            try
            {
                fUseMessageCollector = useMessageCollector;
                fIPAddress = socket.RemoteEndPoint.ToString();
                fConnection = socket;
                fIsConnected = true;

                fReadBufferSize = myTCPListener.ReadBufferSize;
                fReadBuffer = new byte[fReadBufferSize];

                if (myTCPListener.ConnectionTimeOut > 0) //Connection time-out.
                {
                    fConnection.ReceiveTimeout = myTCPListener.ConnectionTimeOut;
                    fConnection.SendTimeout = myTCPListener.ConnectionTimeOut;
                }
                fConnection.ReceiveBufferSize = myTCPListener.ReadBufferSize;
                fConnection.SendBufferSize = myTCPListener.ReadBufferSize;

                fMyListener = myTCPListener;
                fMyExtasysServer = myTCPListener.MyExtasysTCPServer;
            }
            catch (SocketException ex)
            {
                DisconnectMe();
                return;
            }
            catch (Exception ex)
            {
                DisconnectMe();
                return;
            }

            if (fUseMessageCollector)
            {
                fMyMessageCollector = new TCPClientConnectionMessageCollector(this, ETX);
            }

            fMyListener.AddClient(this);
            StartReceivingData();
            
            fConnectionStartUpDateTime = DateTime.Now;
        }
Beispiel #3
0
 /// <summary>
 /// Set my Extasys TCP server.
 /// </summary>
 /// <param name="server">the ExtasysTCPServer main reference at witch this TCPListener belongs.</param>
 public void SetMyExtasysTCPServer(ExtasysTCPServer server)
 {
     fMyExtasysTCPServer = server;
 }
Beispiel #4
0
 /// <summary>
 /// Set my Extasys TCP server.
 /// </summary>
 /// <param name="server">the ExtasysTCPServer main reference at witch this TCPListener belongs.</param>
 public void SetMyExtasysTCPServer(ExtasysTCPServer server)
 {
     fMyExtasysTCPServer = server;
 }