Java UDP packet read failing?

You need to specify the port that the datagram socket is listening on like this: this. So = new DatagramSocket(SOME_NUMBER_HERE) and make sure you send it to the same port number in the send() method.

You need to specify the port that the datagram socket is listening on like this: this. So = new DatagramSocket(SOME_NUMBER_HERE); and make sure you send it to the same port number in the send() method.

DatagramSocket does not specify that. It only reads what is sent to it? This is my code for socket init : this.So = new DatagramSocket(); – Vort3x Sep 26 at 8:49 @Vort3x, it won't hear anything if its not listening to any IP & port.

– Peter Lawrey Sep 26 at 8:51 @Vort3x On the contrary. The Javadoc specifically says that new DatagramSocket() 'binds it to any available port'. So unless you are coincidentally sending to exactly that port, it won't receive those transmissions.

That's the meaning of binding, and port numbers. So don't do that. Try new DatagramSocket(port); where port is the same as you are sending to.

– EJP Sep 26 at 10:26 @EJP THanks, I have misread the doc. I have now bound the port, and it works on localhost. But it won't work across the network, give me a java.net.BindException.

– Vort3x Sep 26 at 10:34 @Vort3x misread or not read? You were pretty dogmatic. Anyway BindException has nothing to do with 'across the network', it just means something else is already listening at that port.

– EJP Sep 26 at 10:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions