Пример #1
0
 public TcpClientConnector()
 {
     _tcpConfiguration      = Configuration.Instance.Setting.TcpConfiguration;
     _connectSocketArgsPool = new SocketArgsPool("TcpClientConnector._connectSocketArgsPool", _tcpConfiguration.ConnectPoolSize, CreateConnectSocketArgs);
     _pendingConections     = new ConcurrentDictionary <Guid, PendingConnection>();
     _timer = new Timer(TimerCallback, null, CheckPeriodMs, Timeout.Infinite);
 }
Пример #2
0
 public TcpClientConnector()
 {
     _tcpConfiguration = Configuration.Instance.Setting.TcpConfiguration;
     _connectSocketArgsPool = new SocketArgsPool("TcpClientConnector._connectSocketArgsPool", _tcpConfiguration.ConnectPoolSize, CreateConnectSocketArgs);
     _pendingConections = new ConcurrentDictionary<Guid, PendingConnection>();
     _timer = new Timer(TimerCallback, null, CheckPeriodMs, Timeout.Infinite);
 }
Пример #3
0
 public TcpServerListener(IPEndPoint serverEndPoint, ISocketServerEventListener eventListener, Action <ITcpConnection, byte[], Action <byte[]> > messageHandler)
 {
     Ensure.NotNull(serverEndPoint, "serverEndPoint");
     Ensure.NotNull(messageHandler, "messageHandler");
     _serverEndPoint       = serverEndPoint;
     _eventListener        = eventListener;
     _messageHandler       = messageHandler;
     _listeningSocket      = new Socket(serverEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     _acceptSocketArgsPool = new SocketArgsPool("TcpServerListener.AcceptSocketArgsPool", Configuration.Instance.Setting.TcpConfiguration.ConcurrentAccepts * 2, CreateAcceptSocketArgs);
     _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
 }
Пример #4
0
 public TcpServerListener(IPEndPoint serverEndPoint, ISocketServerEventListener eventListener, Action<ITcpConnection, byte[], Action<byte[]>> messageHandler)
 {
     Ensure.NotNull(serverEndPoint, "serverEndPoint");
     Ensure.NotNull(messageHandler, "messageHandler");
     _serverEndPoint = serverEndPoint;
     _eventListener = eventListener;
     _messageHandler = messageHandler;
     _listeningSocket = new Socket(serverEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     _acceptSocketArgsPool = new SocketArgsPool("TcpServerListener.AcceptSocketArgsPool", Configuration.Instance.Setting.TcpConfiguration.ConcurrentAccepts * 2, CreateAcceptSocketArgs);
     _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName);
 }
        public TcpServerListener(IPEndPoint serverEndPoint)
        {
            Ensure.NotNull(serverEndPoint, "serverEndPoint");

            _serverEndPoint = serverEndPoint;

            _listeningSocket = new Socket(serverEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            _acceptSocketArgsPool = new SocketArgsPool("TcpServerListener.AcceptSocketArgsPool",
                                                       TcpConfiguration.ConcurrentAccepts*2,
                                                       CreateAcceptSocketArgs);
        }