Example #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;
 }
Example #2
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);
        }
Example #3
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);
        }