コード例 #1
0
ファイル: ServerSocket.cs プロジェクト: zhyzhy782/BodeAbp
        public ServerSocket(IPEndPoint listeningEndPoint, SocketSetting setting, IBufferPool receiveDataBufferPool, Action <ITcpConnection, byte[], Action <byte[]> > messageArrivedHandler)
        {
            listeningEndPoint.CheckNotNull("listeningEndPoint");
            setting.CheckNotNull("setting");
            receiveDataBufferPool.CheckNotNull("receiveDataBufferPool");
            messageArrivedHandler.CheckNotNull("messageArrivedHandler");

            _listeningEndPoint        = listeningEndPoint;
            _setting                  = setting;
            _receiveDataBufferPool    = receiveDataBufferPool;
            _connectionEventListeners = new List <IConnectionEventListener>();
            _messageArrivedHandler    = messageArrivedHandler;
            _socket                      = SocketUtils.CreateSocket(_setting.SendBufferSize, _setting.ReceiveBufferSize);
            _acceptSocketArgs            = new SocketAsyncEventArgs();
            _acceptSocketArgs.Completed += AcceptCompleted;
            _logger                      = IocManager.Instance.Resolve <ILoggerFactory>().Create(GetType().FullName);
        }
コード例 #2
0
 public static string CreateClientId(IPEndPoint clientEndPoint)
 {
     clientEndPoint.CheckNotNull("clientEndPoint");
     return(string.Format("{0}@{1}", clientEndPoint.Address, clientEndPoint.Port));
 }
コード例 #3
0
 public static string ToAddress(this IPEndPoint endpoint)
 {
     endpoint.CheckNotNull("endpoint");
     return(string.Format("{0}:{1}", endpoint.Address, endpoint.Port));
 }