Please give us 60 seconds to demonstrate the simplest, most concise, way of adding network functionality to any .Net application.
Using NetworkComms .net you can send any custom object via TCP or UDP using IPv4 or IPv6 across multiple platforms in just a single line of code. Having said that there are also much more powerful methods/features available (click here for a full feature list):
|
1 2 3 4 5 |
//There are loads of ways of sending data //The most simple, which we use here, just uses an //IP address (string) and port (integer) //We are going to be sending a string object NetworkComms.SendObject("Message", "127.0.0.1", 10000, "Networking in one line!"); |
To receive:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
//We need to define what happens when packets are received. //To do this we add an incoming packet handler for //a 'Message' packet type. // //We will define what we want the handler to do inline by using //a lambda expression //http://msdn.microsoft.com/en-us/library/bb397687.aspx. //We could also just point AppendGlobalIncomingPacketHandler //to a standard method (See other networkcomms.net examples) // //This handler will convert the incoming raw bytes into a string //(this is what the <string> bit does) and then write that //string to the local console window. NetworkComms.AppendGlobalIncomingPacketHandler<string>("Message", (packetHeader, connection, incomingString) => { Console.WriteLine("\n ... Incoming message from " + connection.ToString() + " saying '" + incomingString + "'."); }); //Start listening for incoming 'TCP' connections. The true //parameter means try to use the default port and if that //fails just choose a random port. //See also UDPConnection.StartListening() TCPConnection.StartListening(true); |
There you have it. Only three lines of code (ok, one is a little on the long side).
We happily make NetworkComms.Net freely available via GPLv3. To help keep us warm and our lights on we also provide commercial licences.
To download a working example please click here or see further tutorials here.

Please publish the example to use with Visual Basic 6 soft.
Networks are prone to errors and various other issues. How do you deal with latency and errors in the above code?
@James – You catch various exceptions allowing you how to handle different scenarios however you choose, see API docs then browse NetworkCommDotNet Namespace > CommsException.
@Zhou – In vb.net the only line that changes is the one that calls AppendGlobalIncomingPacketHandler as follows:
Thank you for posting. nice article.