Click or drag to resize

TcpClientOpenAsync(String, Int32, Flags) Method

Opens a TCP connection.

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

Parameters

host  String
The host to connect to.
port  Int32
The port to connect to.
flags  Flags  (Optional)
Connection flags.

Return Value

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

    // Send a message.
    var message = BinaryTextEncoding.NullTerminatedASCII.GetBytes("hello");
    await client.IO.WriteAsync(message);

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