dcsimg
Socket Block read
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Boaz_Inbal
Posted On:   Tuesday, June 11, 2002 10:52 PM

I got a strange behaviour working with standard sockets. When I tried to read the socket buffer using: inStream = new DataInputStream(_clientSocket.getInputStream()); int nRead = inStream.read(recBuffer); It first worked and I got the total bytes. Then it stoped and I get only the first byte and then the rest. Same happened working with: BufferedReader bReader = new BufferedReader( new InputStreamReader( _clientSocket.getInputStream())); int nRead = bReader.read(ch); When I'm performing a loop,nRead gets 1 and in second loop the rest of the length. I get outside the loop using _clientSocket.setSoTimeout(   More>>

I got a strange behaviour working with standard sockets.
When I tried to read the socket buffer using:

			
inStream = new DataInputStream(_clientSocket.getInputStream());
int nRead = inStream.read(recBuffer);

It first worked and I got the total bytes.


Then it stoped and I get only the first byte and then the rest.


Same happened working with:

			
BufferedReader bReader = new BufferedReader(
new InputStreamReader(
_clientSocket.getInputStream()));
int nRead = bReader.read(ch);

When I'm performing a loop,nRead gets 1 and in second loop the rest of the length.
I get outside the loop using

_clientSocket.setSoTimeout(1000);



But this is not what I want.


How can I perform a pure blocking read from the socket???

   <<Less
About | Sitemap | Contact