TCP stream peer.
    public class StreamPeerTCP : StreamPeer

TCP stream peer. This object can be used to connect to TCP servers, or also is returned by a TCP server.

Inheritance Chain


    public StreamPeerTCP()


    public Error ConnectToHost(string host, int port)

Connects to the specified host:port pair. A hostname will be resolved if valid. Returns [constant OK] on success or [constant FAILED] on failure.

    public void DisconnectFromHost()

Disconnects from host.

    public string GetConnectedHost()

Returns the IP of this peer.

    public ushort GetConnectedPort()

    public Status GetStatus()

Returns the status of the connection, see Status.

    public bool IsConnectedToHost()

Returns true if this peer is currently connected to a host, false otherwise.

    public void SetNoDelay(bool enabled)

Disables Nagle’s algorithm to improve latency for small packets.

Note: For applications that send large packets or need to transfer a lot of data, this can decrease the total available bandwidth.

Inner Types


Name Value Description
None 0 The initial status of the [StreamPeerTCP]. This is also the status after disconnecting.
Connecting 1 A status representing a [StreamPeerTCP] that is connecting to a host.
Connected 2 A status representing a [StreamPeerTCP] that is connected to a host.
Error 3 A status representing a [StreamPeerTCP] in error state.