Skip to content
CShift0.32

NetError

Error enum · namespace System.Net · Since 0.30

error NetError

The errors of network connections (TcpListener, TcpConnection).

switch (TcpConnection.Connect("localhost", 8080))
{
case TcpConnection connection: ...; break;
case NetError.CannotConnect: Console.WriteLine("the server does not run"); break;
case error e: Console.WriteLine(e.Message); break;
}
Value Number Description
CannotResolve 1 The name of the host is unknown (or there is no network), or the address is not an IPv4 address.
CannotConnect 2 Nothing listens on the port of the host, or the host cannot be reached.
CannotListen 3 The port is in use (by another program), or the program may not listen on it.
ConnectionLost 4 The connection or the listener is closed, or sending or receiving failed (the other side reset the connection).
NotSupported 5 The platform has no network connections: WebAssembly and AmigaOS.