コード例 #1
0
 public TcpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler <TContext> application, IWorkLoadThrottle connectionThrottle)
     : base(endpoint, new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), settings, connectionThrottle)
 {
     m_activeSockets       = new SocketTable();
     m_forcedAsyncCallback = new WaitCallback(this.ForcedAsyncComplete);
     m_contextPool         = new SynchronizedObjectPool <TContext>(this.Settings.MaxActiveRequests);
     m_completeHandler     = new EventHandler <SocketAsyncEventArgs>(this.AcceptConnection);
     m_handler             = application;
 }
コード例 #2
0
 public SocketServerSettings AsSocketServerSettings()
 {
     SocketServerSettings settings = new SocketServerSettings();
     settings.MaxOutstandingAccepts = this.MaxOutstandingAccepts;
     settings.MaxConnectionBacklog = this.MaxConnectionBacklog;
     settings.MaxActiveRequests = this.MaxActiveRequests;
     settings.ReadBufferSize = this.ReadBufferSize;
     settings.SendTimeout = this.SendTimeout;
     settings.ReceiveTimeout = this.ReceiveTimeout;
     settings.SocketCloseTimeout = this.SocketCloseTimeout;
     return settings;
 }
コード例 #3
0
ファイル: UdpServer.cs プロジェクト: DM-TOR/nhin-d
 public DnsUdpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler<DnsUdpContext> requestHandler, IWorkLoadThrottle workThrottle)
     : base(endpoint, new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp), settings, workThrottle)
 {
     if (requestHandler == null)
     {
         throw new ArgumentNullException();
     }
     
     m_requestHandler = requestHandler;
     m_receiveCompleteHandler = new EventHandler<SocketAsyncEventArgs>(this.ReceiveCompleted);
     m_fromAny = new IPEndPoint(IPAddress.Any, 0);
     m_contextPool = new SynchronizedObjectPool<DnsUdpContext>(this.Settings.MaxActiveRequests);
 }
コード例 #4
0
        public DnsUdpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler <DnsUdpContext> requestHandler, IWorkLoadThrottle workThrottle)
            : base(endpoint, new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp), settings, workThrottle)
        {
            if (requestHandler == null)
            {
                throw new ArgumentNullException();
            }

            m_requestHandler         = requestHandler;
            m_receiveCompleteHandler = new EventHandler <SocketAsyncEventArgs>(this.ReceiveCompleted);
            m_fromAny     = new IPEndPoint(IPAddress.Any, 0);
            m_contextPool = new SynchronizedObjectPool <DnsUdpContext>(this.Settings.MaxActiveRequests);
        }
コード例 #5
0
        public SocketServerSettings AsSocketServerSettings()
        {
            SocketServerSettings settings = new SocketServerSettings();

            settings.MaxOutstandingAccepts = this.MaxOutstandingAccepts;
            settings.MaxConnectionBacklog  = this.MaxConnectionBacklog;
            settings.MaxActiveRequests     = this.MaxActiveRequests;
            settings.ReadBufferSize        = this.ReadBufferSize;
            settings.SendTimeout           = this.SendTimeout;
            settings.ReceiveTimeout        = this.ReceiveTimeout;
            settings.SocketCloseTimeout    = this.SocketCloseTimeout;
            return(settings);
        }
コード例 #6
0
        public SocketServer(IPEndPoint endpoint, Socket listenSocket, SocketServerSettings settings, IWorkLoadThrottle workThrottle)
        {
            if (endpoint == null || listenSocket == null || settings == null)
            {
                throw new ArgumentNullException();
            }

            settings.Validate();
            m_settings = settings;

            m_endpoint     = endpoint;
            m_socket       = listenSocket;
            m_workThrottle = workThrottle ?? settings.CreateRequestThrottle();
            m_outstandingAcceptThrottle = settings.CreateAcceptThrottle();
            m_asyncArgsPool             = new SynchronizedObjectPool <SocketAsyncEventArgs>(m_settings.MaxOutstandingAccepts);
            m_forcedAsyncCallback       = new WaitCallback(this.ForcedAsyncComplete);

            m_listenerThread = new Thread(this.Run);
        }
コード例 #7
0
ファイル: UdpServer.cs プロジェクト: DM-TOR/nhin-d
 public DnsUdpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler<DnsUdpContext> requestHandler)
     : this(endpoint, settings, requestHandler, null)
 {
 }
コード例 #8
0
 public DnsUdpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler <DnsUdpContext> requestHandler)
     : this(endpoint, settings, requestHandler, null)
 {
 }
コード例 #9
0
 public TcpServer(IPEndPoint endpoint, SocketServerSettings settings, IHandler <TContext> application)
     : this(endpoint, settings, application, null)
 {
 }
コード例 #10
0
 public SocketServer(IPEndPoint endpoint, Socket socket, SocketServerSettings settings)
     : this(endpoint, socket, settings, null)
 {
 }