D
Dave Rathnow
Normally I would hang a thread on socket.getInputStream().read()
and wait for a -1 to come back but I've had to use a different
approach. My thread can't block so it is calling
socket.getInputStream().available() to see if anything is waiting and
only then will it read.
while (true) {
if (socket.getInputStream().avilable() > 0)
...read some chars...
}
My problem is I can't tell when the socket is closed by the remote
end. Socket.isClose() always returns false so it's no help. Same with
isConnected(). available() always return 0.
Can anyone tell me the trick?
Thanks,
Dave.
and wait for a -1 to come back but I've had to use a different
approach. My thread can't block so it is calling
socket.getInputStream().available() to see if anything is waiting and
only then will it read.
while (true) {
if (socket.getInputStream().avilable() > 0)
...read some chars...
}
My problem is I can't tell when the socket is closed by the remote
end. Socket.isClose() always returns false so it's no help. Same with
isConnected(). available() always return 0.
Can anyone tell me the trick?
Thanks,
Dave.