B
Brett Everton
Hello,
I have a simple client server application, where the server creates a
socket and listens for a client to connect. Once connected, the server
receives communication from the client via
socketConnection = socketServer.accept();
dataIn = new DataInputStream(socketConnection.getInputStream());
and the server sends out data to the client with
bufferOut = new BufferedWriter(new
OutputStreamWriter(socketConnection.getOutputStream()));
My problem is the client does not detect the end of the stream with
while ((line = bufferIn.readLine()) != null) {
I have read that to cause an EOF in a stream the stream must be
closed, flushing the stream etc is not enough.
My problem is that when i close the stream ( bufferOut ) on the server
side, the client detects the end of the stream but the
socketConnection closes also on the server side.
Can someone explain why I am losing my socket connection just by
closing my bufferedwriter stream? Or let me know a better way to go
about it.
Thanks in advance
Brett
I have a simple client server application, where the server creates a
socket and listens for a client to connect. Once connected, the server
receives communication from the client via
socketConnection = socketServer.accept();
dataIn = new DataInputStream(socketConnection.getInputStream());
and the server sends out data to the client with
bufferOut = new BufferedWriter(new
OutputStreamWriter(socketConnection.getOutputStream()));
My problem is the client does not detect the end of the stream with
while ((line = bufferIn.readLine()) != null) {
I have read that to cause an EOF in a stream the stream must be
closed, flushing the stream etc is not enough.
My problem is that when i close the stream ( bufferOut ) on the server
side, the client detects the end of the stream but the
socketConnection closes also on the server side.
Can someone explain why I am losing my socket connection just by
closing my bufferedwriter stream? Or let me know a better way to go
about it.
Thanks in advance
Brett