示例#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;
 }
 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
 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
 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)
 {
 }