示例#1
0
 /// <summary>
 /// Add new listener with message collector (character splitter).
 /// </summary>
 /// <param name="name">The listener's name.</param>
 /// <param name="ipAddress">The listener's IP address.</param>
 /// <param name="port">The listener's tcp port.</param>
 /// <param name="maxConnections">The number of maximum allowed connections.</param>
 /// <param name="readBufferSize">The read buffer size for each connection in bytes.</param>
 /// <param name="connectionTimeOut">The connections time-out in milliseconds. Set to 0 for no time-out.</param>
 /// <param name="backLog">The number of outstanding connection requests the listener can have.</param>
 /// <param name="splitter">The message splitter.</param>
 /// <returns>The listener.</returns>
 public TCPListener AddListener(string name, IPAddress ipAddress, int port, int maxConnections, int readBufferSize, int connectionTimeOut, int backLog, char splitter)
 {
     TCPListener listener = new TCPListener(name, ipAddress, port, maxConnections, readBufferSize, connectionTimeOut, backLog, splitter);
     listener.SetMyExtasysTCPServer(this);
     fListeners.Add(listener);
     return listener;
 }
        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;
        }
示例#3
0
        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;
        }
示例#4
0
 public TCPListenerThread(TcpListener socket, TCPListener myListener)
 {
     fSocket     = socket;
     fMyListener = myListener;
 }
示例#5
0
 public TCPListenerThread(TcpListener socket, TCPListener myListener)
 {
     fSocket = socket;
     fMyListener = myListener;
 }