Click or drag to resize

TcpClientOpenStream Method

Opens a TCP connection.

Namespace: Demo3D.Net.Protocols
Assembly: Demo3D.IO (in Demo3D.IO.dll) Version: 19.00.00
Syntax
C#
public static Client<IByteStreamService> OpenStream(
	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

ClientIByteStreamService
A new TCP client.
Remarks
Don't use blocking methods in Demo3D scripting. Consider using OpenAsync(Boolean, String, Int32, Flags) instead.
Example
C#
public void SendMessage(string host, int port) {
    // Open a connection to a client.
    var client = TcpClient.OpenStream(host, port);

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

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