虽然没有任何东西阻止你撰写所有低层次的网络密码,但使用图书馆无疑是节省时间和压力的巨大途径,因此,你可以更好地利用时间改进自己的应用。
http://www.networkcomms.net>networkComms.net。 它有许多复杂的特征(例如序列化、压缩和加密),但鉴于你提到多少连接,它能够处理1千+的传输率。 how to establish a briefuser Service application,但简言之,您可以寄送并接收如下内容。
派遣:
//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!")
接收:
//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("
... 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);
申斥: 图书馆开发商之一。