Пример #1
0
        public TcpSocketSession(TcpClient tcpClient, TcpSocketServerConfiguration configuration
                                , ISegmentBufferManager bufferManager, TcpSocketServer server)
        {
            if (tcpClient == null)
            {
                throw new ArgumentNullException("tcpClient");
            }
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _tcpClient     = tcpClient;
            _configuration = configuration;
            _bufferManager = bufferManager;
            _server        = server;

            _sessionKey    = Guid.NewGuid().ToString();
            this.StartTime = DateTime.UtcNow;

            SetSocketOptions();

            _remoteEndPoint = this.RemoteEndPoint;
            _localEndPoint  = this.LocalEndPoint;
        }
Пример #2
0
        public TcpSocketServer(IPEndPoint listenedEndPoint, TcpSocketServerConfiguration configuration = null)
        {
            if (listenedEndPoint == null)
            {
                throw new ArgumentNullException("listenedEndPoint");
            }

            this.ListenedEndPoint = listenedEndPoint;
            _configuration        = configuration ?? new TcpSocketServerConfiguration();

            if (_configuration.BufferManager == null)
            {
                throw new InvalidProgramException("The buffer manager in configuration cannot be null.");
            }
            if (_configuration.FrameBuilder == null)
            {
                throw new InvalidProgramException("The frame handler in configuration cannot be null.");
            }
        }
Пример #3
0
 public TcpSocketServer(IPAddress listenedAddress, int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), configuration)
 {
 }
Пример #4
0
 public TcpSocketServer(int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, configuration)
 {
 }