| Author |
problem in reading input stream from a socket
|
jitendra kumar sharma
Greenhorn
Joined: Dec 30, 2009
Posts: 2
|
|
I have created a socket to a linux machine on my local network, socket is created and connected successfully, then I have created one DataInputStream and one DataOutputStream by socket. writing a byte array and length of byte array to output stream and then flush output stream. But when I try to read input stream it is blocked due to no data is available in input stream, I check this by available() method.
However, I connected to this socket in iphone and flex successfully, can anyone suggest me what should i do to resolve this.
thanks in advance.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Available doesn't do what you think it does
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
jitendra kumar sharma
Greenhorn
Joined: Dec 30, 2009
Posts: 2
|
|
I have solved this problem,
but when i tried my code in android application, I am getting same error, my code as follows:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Please Use Code Tags. I've added them for you this time.
I see you still use available(). Why? If you want to use non-blocking I/O check out SocketChannel in combination with a Selector instead.
|
 |
 |
|
|
subject: problem in reading input stream from a socket
|
|
|