IEndPoint

Description

interface Tinman.Core.IO.Sockets.IEndPoint

Extended by

SocketEndPoint sealed

Base interface for classes that represent network addresses resp. endpoints.

A typical usage of network endpoints looks like this (A and B refer to the participants):

  1. A chooses an unused IEndPoint and calls CreateServer to create a IServer object.

  2. A calls IServer.Accept to accept an incoming connection and obtains a IConnection object.

  3. B chooses a suitable IEndPoint, calls OpenConnection to connect to the server of A and receives a IConnection object.

  4. A and B use the IConnection.Send and IConnection.Receive methods to transfer data.

A graceful shutdown of a network connection can be performed in the following way:

  1. Either side calls IConnection.Close.

  2. The other side receives false when calling IConnection.Receive.

A forceful shutdown of a network connection is performed like this:

  1. Either side calls IConnection.Discard or A calls IDisposable.Dispose on its server.

  2. The other side gets an IOException when calling IConnection.Send or IConnection.Receive.

Public / Methods

Create​Server


[OwnerReturn]
public method CreateServer → ()

returns → IServer

The created network server or null iff the endpoint is already in use (for example by another IServer instance of by another system process).

Creates a new network server that listens on this endpoint.

A system resource of a network endpoint may remain in an unusable state after the owning IServer object has been disposed (for example, TCP/IP connections enter the TIME_WAIT state after an active close). Client code must take that into account when creating servers on the same endpoint repeatedly, for example when running unit tests.

IOException

If an I/O error has occurred.

Open​Connection


[OwnerReturn]
public method OpenConnection → (1)

timeout opt : int32 = 5000

[>=0]
The connection timeout in milliseconds or 0 for no timeout.

returns → IConnection

The created network connection or null if timeout opt has elapsed.

Opens a new network connection to this endpoint.

IOException

If an I/O error has occurred.