by EJP <esmond.not.pitt@[EMAIL PROTECTED]
>
Apr 16, 2008 at 11:50 AM
Chase Preuninger wrote:
> if(s.getInetAddress().getHostAddress().equalsIgnoreCase(validIP))
I suggest that this test is failing, so you are writing nothing and
immediately closing the socket, hence the immediate read() returning -1
at the receiver. I would print a trace if this test fails, as surely you
want to know about invalid source addresses, as well as debug this
problem.
> s.close();
Wrong. You should always close the outermost output stream of the
socket, and closing a socket or its output stream or its input stream
closes the other two.
> while(!s.isClosed() && (b = in.read()) != -1)
The s.isClosed() test here is pointless, unless you have another thread
that might close the socket. It won't tell you when you have reached
EOF. read() returning -1 tells you that.
> s.close();
See above. Close the output stream only.