TcpClientOpen Method (String, Int32, Flags) |
Namespace: Demo3D.Net.Protocols
public static Client<IPacketIOService> Open( string host, int port, Flags flags = default )
public void SendMessage(string host, int port) { // Open a connection to a client. var client = TcpClient.Open(host, port); // Send a message. var message = BinaryTextEncoding.NullTerminatedASCII.GetBytes("hello"); client.IO.Write(message); // Close the connection. client.Close(); }
public Client<IPacketIOService> OpenClient(string host, int port) { // Create a connection to a client, without opening it. var client = TcpClient.Open(host, port, OpenFlags.NoOpen); // Get the protocol properties and set TCP.ReceiveTimeout to 1 second. dynamic properties = client.Properties; properties.TCP.ReceiveTimeout = 1000; // Open the connection. client.Open(); return client; }