Esempio n. 1
0
        public TcpSocketSession(
            TcpClient tcpClient,
            TcpSocketServerConfiguration configuration,
            IBufferManager 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;

            ConfigureClient();

            _remoteEndPoint = Active ? (IPEndPoint)_tcpClient.Client.RemoteEndPoint : null;
            _localEndPoint = Active ? (IPEndPoint)_tcpClient.Client.LocalEndPoint : null;
        }
Esempio n. 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.FrameBuilder == null)
                throw new InvalidProgramException("The frame handler in configuration cannot be null.");

            Initialize();
        }
Esempio n. 3
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.");
        }
Esempio n. 4
0
        public TcpSocketSession(
            TcpClient tcpClient,
            TcpSocketServerConfiguration configuration,
            IBufferManager 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;

            ConfigureClient();

            _remoteEndPoint = Active ? (IPEndPoint)_tcpClient.Client.RemoteEndPoint : null;
            _localEndPoint  = Active ? (IPEndPoint)_tcpClient.Client.LocalEndPoint : null;
        }
Esempio n. 5
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;

            this.StartTime = DateTime.UtcNow;

            SetSocketOptions();

            _remoteEndPoint = this.RemoteEndPoint;
            _localEndPoint  = this.LocalEndPoint;
            _sessionKey     = configuration.SessionKeyBuilder.GetSessionKey(this.RemoteEndPoint.ToString());
        }
Esempio n. 6
0
 public TcpSocketServer(IPAddress listenedAddress, int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), configuration)
 {
 }
Esempio n. 7
0
 public TcpSocketServer(int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, configuration)
 {
 }
Esempio n. 8
0
 public TcpSocketServer(IPAddress listenedAddress, int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), configuration)
 {
 }
Esempio n. 9
0
 public TcpSocketServer(int listenedPort, TcpSocketServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, configuration)
 {
 }