dcsimg
How do I send an EOF over a OutputStream?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, April 8, 2002 03:40 PM

I have client and server code and I am writing image bytes to the server using an OutputStream. The server has to read all the bytes before it processes them and writes them back to the client. The problem is that once the server has read all the bytes it still waits on the read for more bytes. How do I send EOF so that the read method will exit? Client: toServer.write(HeaderBytes); toServer.write(contentBytes); toServer.flush(); Server: ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; while((last_read_byte = from_client.read(buffer)) != -1) { byteStream.write(buffer,0,last_read_b   More>>

I have client and server code and I am writing image bytes to the server using an OutputStream.
The server has to read all the bytes before it processes them and writes them back to the client.
The problem is that once the server has read all the bytes it still waits on the read for more bytes.
How do I send EOF so that the read method will exit?

Client:

			
toServer.write(HeaderBytes);
toServer.write(contentBytes);
toServer.flush();


Server:
			
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while((last_read_byte = from_client.read(buffer)) != -1)
{
byteStream.write(buffer,0,last_read_byte);
}



Thanks,
Vidula    <<Less
About | Sitemap | Contact