Forums Register Login

Simple problem in running a Server class

+Pie Number of slices to send: Send
Hello,
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 :
javac Server.java
// this works well but when i try to run it using this command:
java Server
//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)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.DatagramSocket.<init>(DatagramSocket.java:210)
at java.net.DatagramSocket.<init>(DatagramSocket.java:261)
at java.net.DatagramSocket.<init>(DatagramSocket.java:234)
at Server.main(Server.java:8)

How can i get rid of this problem?
thanks in advance
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks tom , this is already the case
I've reboot it and it it works well
Hey! You're stepping on my hand! Help me tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 5500 times.
Similar Threads
Problem regarding socket time out exception.
Pinger time!
Network assignment HELP NEEDED
String object != String object?
java udp socket programming problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:24:46.