Exemplo 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="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);
        }
Exemplo 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="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 = AddressFamily.InterNetwork;
            IPAddress     bindAddress   = IPAddress.Any;

            _socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.Bind(new IPEndPoint(bindAddress, port));
            _socket.Listen(64);
        }
Exemplo 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="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);
        }
Exemplo n.º 4
0
 public HTTPServerSession(Socket socket, HTTPServerParams parameters)
 {
     _socket      = socket;
     _params      = parameters;
     _maxRequests = parameters.MaxRequests;
 }
 public HTTPServerSession(Socket socket, HTTPServerParams parameters)
 {
     _socket = socket;
     _params = parameters;
     _maxRequests = parameters.MaxRequests;
 }
Exemplo n.º 6
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 = AddressFamily.InterNetwork;
            IPAddress bindAddress = IPAddress.Any;

            _socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.Bind(new IPEndPoint(bindAddress, port));
            _socket.Listen(64);
        }