/// <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; }
public TCPListenerThread(TcpListener socket, TCPListener myListener) { fSocket = socket; fMyListener = myListener; }