Skip to main content

HttpListener Class

Namespace: System.Net · Assembly: GHIElectronics.TinyCLR.Networking.Http

Provides a simple, programmatically controlled HTTP protocol listener. This class cannot be inherited.

public class HttpListener

Constructors

HttpListener(string prefix)

public HttpListener(string prefix)

Creates an HTTP or HTTPS listener on the standard ports.

ParameterTypeDescription
prefixstringPrefix ( http or https ) to start listen

HttpListener(string prefix, int port)

public HttpListener(string prefix, int port)

Creates an HTTP or HTTPS listener on the specified port.

ParameterTypeDescription
prefixstringThe prefix for the service, either "http" or "https".
portintThe port to start listening on. If -1, the default port is used (port 80 for http, or port 443 for https).

Properties

IsListening

public bool IsListening { get; }

Gets whether the HttpListener service was started and is waiting for client connections.

MaximumResponseHeadersLength

public int MaximumResponseHeadersLength { get; set; }

Gets or sets the maximum allowed length of the response headers, in KB.

AuthenticationSchemes

public AuthenticationSchemes AuthenticationSchemes { get; set; }

Gets or sets the scheme used to authenticate clients.

Realm

public string Realm { get; set; }

Gets or sets the realm associated with this listener.

IgnoreWriteExceptions

public bool IgnoreWriteExceptions { get; set; }

Gets or sets a value that indicates whether this listener silently swallows exceptions thrown when sending the response to the client.

IsSupported

public static bool IsSupported { get; }

Indicates whether HttpListener can be used with the current runtime. Always returns true on TinyCLR.

HttpsCert

public X509Certificate HttpsCert { get; set; }

The certificate used if HttpListener implements an https server.

Methods

Abort()

public void Abort()

Shuts down the HttpListener object immediately, discarding all currently queued requests.

Start()

public void Start()

Allows this instance to receive incoming requests.

Close()

public void Close()

Shuts down the HttpListener after processing all currently queued requests.

Stop()

public void Stop()

Causes this instance to stop receiving incoming requests.

GetContext()

public HttpListenerContext GetContext()

Waits for an incoming request and returns when one is received.

Returns HttpListenerContext — An System.Net.HttpListenerContext object that represents a client request.