Click or drag to resize

TcpClientOpenStreamAsync Method (String, Int32, Flags)

Opens a TCP connection.

Namespace:  Demo3D.Net.Protocols
Assembly:  Demo3D.IO (in Demo3D.IO.dll) Version: 15.0.2.11458
Syntax
C#
public static Task<Client<IByteStreamService>> OpenStreamAsync(
	string host,
	int port,
	Flags flags = default
)

Parameters

host
Type: SystemString
The host to connect to.
port
Type: SystemInt32
The port to connect to.
flags (Optional)
Type: Demo3D.NetFlags
Connection flags.

Return Value

Type: TaskClientIByteStreamService
A new TCP client.
Examples
C#
public async Task SendMessageAsync(string host, int port) {
    // Open a connection to a client.
    var client = await TcpClient.OpenStreamAsync(sync: false, host, port);

    // Send a message.
    var message = new byte[4];
    await client.IO.Stream.WriteAsync(message, 0, message.Length);

    // Close the connection.
    client.Close();
}
See Also