2. How can you check that both sides are active?
I have tried the setKeepAlive(true) and checking with isConnected() which returns true even if the other side is long gone.
3. The isPending(SOCKET_PENDING_INPUT,2000) seems to indicate that data is available even if the other side is long gone.
4. What does endl do for the functionality?
Will it insert a new-line in the string or will
it call sync() to send data?
What Im looking for really, is an example of sending/reading data.
Is there anyone out there that could help me out?
Kind regards
Anders.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all.
I have recently started to look into the Networking functionality of CommonC++.
I have been using the Threads for a while (Works great by the way).
Im trying to use the TCPStream and build a client server.
Im having problems using it. The example (tcp.cpp) is not complete? It seems to me that there is a client missing?
I have several problems:
1. If I send a string with:
tcp<<"Hello world" << endl;
It will be read on the other side as:
tcp >> buffer; // Contains "Hello"
tcp >> buffer; // Contains "world"
2. How can you check that both sides are active?
I have tried the setKeepAlive(true) and checking with isConnected() which returns true even if the other side is long gone.
3. The isPending(SOCKET_PENDING_INPUT,2000) seems to indicate that data is available even if the other side is long gone.
4. What does endl do for the functionality?
Will it insert a new-line in the string or will
it call sync() to send data?
What Im looking for really, is an example of sending/reading data.
Is there anyone out there that could help me out?
Kind regards
Anders.
There actually is a "client" example now found in urlfetch.cpp that uses the URLStream class.
1.
You may need to use the getline() method for line oriented parsing.
2.
The eof() indicator should show when a remote connection has gone.
3.
You can also do a SOCKET_PENDING_ERROR to test the exception status.
4.
endl performs a flush and adds '\n'.