我正在为我的XNA游戏试验Lidgren库。我创建了一个简单的服务器和客户机:服务器:
NetPeerConfiguration config = new NetPeerConfiguration("Warz");
config.Port = port;
server = new NetServer(config);
config.MaximumConnections = 500;
server.Start();
logMessage("Server starting on port " + port.ToString(), ConsoleColor.Green);
Console.Read();客户端:
NetPeerConfiguration netConfig = new NetPeerConfiguration("Warz");
netConfig.Port = 1000;
client = new NetClient(netConfig);
client.Start();
client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), port));Port是一个值为1000的整数,错误发生在我启动服务器后的client.connect方法上。错误是:无法绑定到端口0.0.0.0:1000 -地址已在使用中!我听说了什么关于重用地址的事?找不到解决问题的办法。
谢谢!!
发布于 2012-04-11 16:57:12
我找到了解决方案,在客户机上我不应该在NetPeerConfiguration中设置端口,因为它已经在client.connect中设置了。当我移除它的时候,它又像一个护身符一样起作用了。谢谢你的努力,Rene!
发布于 2012-04-11 16:45:34
端口可能正在使用中。试试像26648这样的东西。
https://stackoverflow.com/questions/10093695
复制相似问题