NetworkComms V3 support of TCP and UDP connections

NetworkComms V3 seamless support for TCP and UDP connections.

You can easily create both connections



// create a connection information object
ConnectionInfo ConnInfo = new new ConnectionInfo ( "192.168.0.1", 10000);

// create a TCP connection
Connection newTCPConn = TCPConnection.GetConnection (ConnInfo);

// create a UDP connection
Connection newUDPConn = UDPConnection.GetConnection (connInfo, UDPOptions.None);

Simple usage example:


// processing method as specified message type "StringMessage" message
newConn.AppendIncomingPacketHandler <String> ( "StringMessage",
MethodToRunForStringMessage,
NetworkComms.DefaultSendReceiveOptions);

// run-off method in connection
newConn.AppendShutdownHandler (MethodToRunOnConnectionClose);

// send a custom object with the message type "CustomObject1"
newConn.SendObject ( "CustomObject1", CustomObject);


// send a message of type "CustomObject1", the expected return message type "CusotmObject2" message
customObject2 customObject2 = newConn.SendReceiveObject < CustomObject1, CustomObject2> ( "CustomObject1",
"CustomObject2",
1000,
CustomObject);

// close the connection
newConn.CloseConnection (false);

Original: http: //www.networkcomms.net/tcp-udp-connections/

www.networkcomms.cn finishing
---------------------
Author: networkcomms
Source: CSDN
Original: https: //blog.csdn.net/networkcomms/article/details / 44218173
copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/Jeely/p/10972228.html