Although nothing prevents you from writing all the low-level network code yourself, using the library is a great way to save a ton of time and stress, time that you can better spend on improving your own application.
A library not mentioned here is networkComms.net . It has many complex features (such as serialization, compression, and encryption), but given the number of connections mentioned, it is capable of handling 1000+ connections at a transmission rate of 1 Gbit / s +. There is a simple article on how to create a fast client-side server application , but in short you can send and receive the following.
Submit:
//This is the simplest way to send with more advanced options also available //Parameters are message type, IP address, port and the object to send NetworkComms.SendObject("Message", "127.0.0.1", 10000, "Networking in one line!")
Receive:
//We need to define what happens when packets are received. //To do this we add an incoming packet handler for //a 'Message' packet type. // //This handler will automatically 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);
Disclaimer: I am one of the developers of this library.
Marcf source share