1

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!!

3
  • It's rather unclear on what line the error is occurring. Is it in the client, or server? What line? Can you copy the exact exception that Visual Studio gives you? Also, what is the variable "port" in the server code set to? Apr 11, 2012 at 8:30
  • 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!
    – Basaa
    Apr 11, 2012 at 8:34
  • Please edit your original post with the above information. Apr 11, 2012 at 8:35

2 Answers 2

1

The port might be in use. Try something like 26648.

0
1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.