Esempio n. 1
0
        /// <summary>
        /// Create an HTTPServer.
        /// </summary>
        /// <param name="factory">The RequestHandlerFactory that will instantiate the
        /// Request handler(s) for this server.</param>
        /// <param name="port">The port on which to listen for connections. The socket
        /// will be created and bound to all interfaces by the HTTPServer</param>
        /// <param name="parameters">The parameters used for this server.</param>
        public HTTPServer(IHTTPRequestHandlerFactory factory, int port, HTTPServerParams parameters)
        {
            _factory = factory;
            _params  = parameters;

            _socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
            _socket.Bind(new IPEndPoint(IPAddress.IPv6Any, port));
            _socket.Listen(64);
        }
Esempio n. 2
0
        /// <summary>
        /// Create an HTTPServer.
        /// </summary>
        /// <param name="factory">The RequestHandlerFactory that will instantiate the
        /// Request handler(s) for this server.</param>
        /// <param name="socket">The socket on which this server will listen for
        /// connections. The socket must be bound to an endpoint prior to creating
        /// the server.</param>
        /// <param name="parameters">The parameters used for this server.</param>
        public HTTPServer(IHTTPRequestHandlerFactory factory, Socket socket, HTTPServerParams parameters)
        {
            if (!socket.IsBound)
            {
                throw new HTTPException("The socket must be bound.");
            }

            _factory = factory;
            _socket  = socket;
            _params  = parameters;

            _socket.Listen(64);
        }
Esempio n. 3
0
        /// <summary>
        /// Create an HTTPServer.
        /// </summary>
        /// <param name="factory">The RequestHandlerFactory that will instantiate the
        /// Request handler(s) for this server.</param>
        /// <param name="port">The port on which to listen for connections. The socket
        /// will be created and bound to all interfaces by the HTTPServer</param>
        /// <param name="parameters">The parameters used for this server.</param>
        public HTTPServer(IHTTPRequestHandlerFactory factory, int port, HTTPServerParams parameters)
        {
            _factory = factory;
            _params  = parameters;

            AddressFamily addressFamily;
            IPAddress     bindAddress;

            if (Socket.OSSupportsIPv6)
            {
                addressFamily = AddressFamily.InterNetworkV6;
                bindAddress   = IPAddress.IPv6Loopback;
            }
            else
            {
                addressFamily = AddressFamily.InterNetwork;
                bindAddress   = IPAddress.Loopback;
            }

            _socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.Bind(new IPEndPoint(bindAddress, port));
            _socket.Listen(64);
        }
 public HTTPServerSession(Socket socket, HTTPServerParams parameters)
 {
     _socket      = socket;
     _params      = parameters;
     _maxRequests = parameters.MaxRequests;
 }