I've developed a client/server application to send datagram packets and receive them through the UDP protocol using two classes
this is the Server class
this is the Client class
The problem is that when i try to run the server class from the command prompt :
// this works well but when i try to run it using this command:
//it throws this exception:
Exception in thread "main" java.net.SocketException: Unrecognized Windows Sockets error: 0: Cannot bind
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
How can i get rid of this problem?
thanks in advance
I Hear I Forget, I See I Remember, I Do I Understand.
I Googled the error and a couple of items suggested that the port is already in use. I noticed that your server loops forever and does not clean up after itself (by calling DatagramSocket.close). Could it be that another instance is already running? Or maybe not cleaning up caused the port to remain open? Or perhaps another application is using that port? Try using another port or rebooting to close the existing port (both easy tests).
I tried running your server and got a different error (Address already in use) when I tried running it a second time but I'm not running on Windows.