I'm experimenting with the Lidgren library for my XNA game. I created a simple server and client: Server:
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();
Client:
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 is an integer with the value 1000, the error occures on the client.connect method after I started the server. The error is: Failed to bind to port 0.0.0.0:1000 - Address already in use! I heard something about the option reuseaddress? Can't find out how to fix it tough.
Thanks!!
I found the solution, on the client I should not set the port in the NetPeerConfiguration because it's set in the client.connect already. when I removed it it worked like a charm again. Thanks for your effort, Rene!