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

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
Basaa
  • 151
  • 2
  • 13
  • 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? – René Sackers Apr 11 '12 at 08: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 '12 at 08:34
  • Please edit your original post with the above information. – René Sackers Apr 11 '12 at 08:35

2 Answers2

1

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

René Sackers
  • 2,395
  • 4
  • 24
  • 43
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!

Basaa
  • 151
  • 2
  • 13