我一直在为C#寻找一个像样的网络库。它将用于XNA3.1和.NET Framework3.5。多玩家风格将是服务器和客户端。目前我一直在研究Lidgren Library Network,但它似乎已经过时了。
对于一个好的网络图书馆,任何人都有一些好的建议。它应该能够一次轻松地处理30+客户端连接。
发布于 2010-05-30 01:17:04
您的链接确实过时了;但是如果您阅读了该页面,它会将您引导至较新的版本:http://code.google.com/p/lidgren-network-gen3/
发布于 2013-02-11 20:51:16
虽然没有什么可以阻止你自己编写所有的底层网络代码,但是使用库绝对是一种很好的方式来节省大量的时间和压力,这样你就可以更好地花在改进自己的应用程序上。
这里没有提到的一个库是networkComms.net。它有很多复杂的功能(如串行化、压缩和加密),但考虑到你提到的连接数量,它能够以1Gbps+的传输率处理1000+连接。在how to create a quick client server 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("\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);免责声明:我是这个库的开发者之一。
发布于 2010-05-22 20:15:04
你好像找错地方了。您似乎没有查看过.NET框架本身。
使用WCF怎么样?使用TcpListener怎么样?
你需要什么是这些不能提供的?
https://stackoverflow.com/questions/2888012
复制相似问题