Hi,

>     I have edited your code.  It is working fine, except for few changes.

Thanks.  However, my original email was essentially a bug report, not a
request for help with my code.  I didn't actually say "bug report" because
so many bug reports end up just being problems with people's code.  I
believe my code as originally posted was valid (and reasonable!) and that
the Blackdown Linux JDK is doing something wrong.

The changes you made are the obvious ways to work around this
bug.  However, there are some remaining problems.

You changed
   socket = new DatagramSocket();
to
   socket = new DatagramSocket(2000,InetAddress.getLocalHost());

where you have arbitrarily chosen port 2000.  I really do want the correct
behaviour of the argument-less DatagramSocket() constructor: to pick an
unused port.  It would be possible to, starting at a random number, look
for an unused port, but this is ugly when a constructor that does exactly
what I want already exists.

>     The sender to the same port you are listening to else you will get a time
> out error.

If I wanted to talk to myself..... :)  This of course not the point of the
exercise.  The address I chose for the send() was completely
arbitrary.  For my application, it will be the address of the server, of
course.

>     Instead of socket.getLocalAddress().getHostAddress() use InetAddress.
> getLocalhost(). The former gives 0.0.0.0.

Yes, I noticed.  If I wanted the address of the local host, I would use
InetAddress.getLocalhost().  What I wanted to demonstrate in my small test
class was the behaviour of DatagramSocket.getLocalAddress().  The Linux
JDK behaviour in this case actually matches the Solaris behaviour.  8-)

>     These make the program work successfully.

By working around the problem.

This email might sound rude - it's not meant to be!  I'm just pointing out
that you're showing me how to work around what I believe is a bug, without
addressing whether it actually is a bug, or addressing what to do to fix
the bug.

After writing this I checked the bug database at java.sun.com.  There were
several reports of this happening in some flavours of Windoze and one
flavour of Redhat.  They claim to have fixed the problem in Merlin aka
1.4.  The solution is thus simple: wait!

Thanks for your response!

Cheers,
dustin.



----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to