B
Bob
Hi guys,
I would like to implement a simple http-like client: the client should
send a request, wait for reply from the server and then terminate the
communication.
I am trying to implement this using a PrintSream implementation of an
outputstream.
Here's a simple version of the client code:
----------- C L I E N T -------------
1. String message = buildMessage();
2.
3. printStream.write(message.getBytes());
4. printStream.flush();
5.
6. waitForReply();
7. closeSocket();
-----------------------------------------
on the other hand the server does something like (very simplified)
------------ S E R V E R --------
1. while(r!=1){
2. r = inputStream.read(...);
3. ...
4. }
5. sendReply();
-----------------------------------
My problem is that line "5" of the server is never executed, which
means that the condition "the end of the stream has been reached" is
never met (according to the read method's apidocs).
My question is how to make it explicit (or even implicit, I don't mind)
on the client-site that the end of the request has been reached.
i.e. is there anything like:
printStream.this_Is_The_End_Of_The_Stream(); (?)
or do I need to explicitly send an EOF character?
Thanks, and sorry for the long message,
Bob
I would like to implement a simple http-like client: the client should
send a request, wait for reply from the server and then terminate the
communication.
I am trying to implement this using a PrintSream implementation of an
outputstream.
Here's a simple version of the client code:
----------- C L I E N T -------------
1. String message = buildMessage();
2.
3. printStream.write(message.getBytes());
4. printStream.flush();
5.
6. waitForReply();
7. closeSocket();
-----------------------------------------
on the other hand the server does something like (very simplified)
------------ S E R V E R --------
1. while(r!=1){
2. r = inputStream.read(...);
3. ...
4. }
5. sendReply();
-----------------------------------
My problem is that line "5" of the server is never executed, which
means that the condition "the end of the stream has been reached" is
never met (according to the read method's apidocs).
My question is how to make it explicit (or even implicit, I don't mind)
on the client-site that the end of the request has been reached.
i.e. is there anything like:
printStream.this_Is_The_End_Of_The_Stream(); (?)
or do I need to explicitly send an EOF character?
Thanks, and sorry for the long message,
Bob