Class HttpServer
A simple HTTP server.
Namespace: NanoByte.Common.Net
Assembly: NanoByte.Common.dll
Syntax
public abstract class HttpServer : Object
Constructors
HttpServer(UInt16, Boolean)
Gets ready to serve HTTP requests. Call StartHandlingRequests() after completing any additional setup.
Declaration
protected HttpServer(ushort port = 0, bool localOnly = false)
Parameters
Type | Name | Description |
---|---|---|
UInt16 | port | The TCP port to listen on; |
Boolean | localOnly |
|
Exceptions
Type | Condition |
---|---|
WebException | Unable to serve on the specified |
NotAdminException | Needs admin rights to serve HTTP requests. |
Properties
Port
The TCP port the server is listing on.
Declaration
public ushort Port { get; }
Property Value
Type | Description |
---|---|
UInt16 |
Methods
Dispose()
Stops serving HTTP requests.
Declaration
public virtual void Dispose()
HandleRequest(HttpListenerContext)
Handles a single HTTP request.
Declaration
protected abstract void HandleRequest(HttpListenerContext context)
Parameters
Type | Name | Description |
---|---|---|
HttpListenerContext | context |
StartHandlingRequests()
To be called by derived constructor when setup is complete.
Declaration
protected void StartHandlingRequests()