I've gone through the documentation and the source, and just can't make it work. I'm trying to make a simple server which sends a message to the client, receive a short message and then send it back.
I used the tcp program in the demo. I added the following snippet in the main while loop of the program, between the opening and close.
if (tcp.isPending(SOCKET_PENDING_INPUT, 2000) {
tcp >> i;
tcp << i << "*" << endl;
}
I'm just dumb founded in making this work. I haven't been able to find any other examples.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a possibility the problem here is with poll() on your machine. With 0.9.3, poll() is favored over select(). If you do not use the pending for timeouts, does it operate for you? And what target platform, compiler, etc, are you having this problem with?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
poll() is available. the system is solaris 2.6, with gcc 2.95.1. No value is ever retreived from the stream. And writing to the stream after attempting to read from it fails. This includes other clients which connect.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have modified tcp.cpp in a similar manner in an attempt to see if
I can duplicate this problem. I have also checked the modified tcp.cpp into cvs. I have only tried it under Linux so far, using a telnet client, and the behavior seems to be correct; if you enter a number within two seconds (and a c/r), you will get a number written back to you in the following tcp << ... statement. Please verify that my modified tcp.cpp does correctly simulate your question, and see if you still get the same behavior.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
gptr should get set from the TCPStream::Allocate method that is called for open through the setg() which constructs the stream buffers and sets streambuf pointers to them. Perhaps there is something different going on in the Solaris C++ library in regards
to setg()??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All I have been able to determine on this is that a setb() may be needed before the setg() in both ::Allocate and ::sync(). Please try the socket.cpp from cvs and let me know if this fixes your Solaris
problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
unfortunately it doesn't fix the solaris problem. i tried it on another solaris machine with a different build of gcc. The problem exists there...
gbuf is being set to null on the "tcp >> i;" line. the address of gbuf is set in ::Allocate, but afterwards it's set to null before entering ::underflow.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One thing I did figure out is that "clear()" needs to be called before the setb(). This clears any error states that may have been left-over
from when tcpstream was last opened and closed. However, I do
not believe this fixes your problem in of itself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
unfortunately it doesn't. the project i was hoping to use your classes on has been finished... i ended writing a method to retrieve the socket descriptor (so). And constructing an fstream using it... and then doing stream io through the fstream....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've gone through the documentation and the source, and just can't make it work. I'm trying to make a simple server which sends a message to the client, receive a short message and then send it back.
I used the tcp program in the demo. I added the following snippet in the main while loop of the program, between the opening and close.
if (tcp.isPending(SOCKET_PENDING_INPUT, 2000) {
tcp >> i;
tcp << i << "*" << endl;
}
I'm just dumb founded in making this work. I haven't been able to find any other examples.
There is a possibility the problem here is with poll() on your machine. With 0.9.3, poll() is favored over select(). If you do not use the pending for timeouts, does it operate for you? And what target platform, compiler, etc, are you having this problem with?
poll() is available. the system is solaris 2.6, with gcc 2.95.1. No value is ever retreived from the stream. And writing to the stream after attempting to read from it fails. This includes other clients which connect.
I will try to create a test case app for this, and see what I find playing with it.
I have modified tcp.cpp in a similar manner in an attempt to see if
I can duplicate this problem. I have also checked the modified tcp.cpp into cvs. I have only tried it under Linux so far, using a telnet client, and the behavior seems to be correct; if you enter a number within two seconds (and a c/r), you will get a number written back to you in the following tcp << ... statement. Please verify that my modified tcp.cpp does correctly simulate your question, and see if you still get the same behavior.
tested in Linux. works how i expected it to work. After building it on Solaris the program fails. exactly like what i was trying to do.
in TCPStream::undeflow() gptr() is NULL so it's returning EOF
gptr should get set from the TCPStream::Allocate method that is called for open through the setg() which constructs the stream buffers and sets streambuf pointers to them. Perhaps there is something different going on in the Solaris C++ library in regards
to setg()??
something is going wrong with the iostream library... it wants to reset the read_ptr when it attempts to read.
hmm...when I get a chance to use a Solaris box, I will want to look into this more myself. Very odd.
All I have been able to determine on this is that a setb() may be needed before the setg() in both ::Allocate and ::sync(). Please try the socket.cpp from cvs and let me know if this fixes your Solaris
problem.
unfortunately it doesn't fix the solaris problem. i tried it on another solaris machine with a different build of gcc. The problem exists there...
gbuf is being set to null on the "tcp >> i;" line. the address of gbuf is set in ::Allocate, but afterwards it's set to null before entering ::underflow.
Do you suppose any use could be made of "setbuf". This is very
strange, and something I have been unable to duplicate elsewhere (non-Solaris).
One thing I did figure out is that "clear()" needs to be called before the setb(). This clears any error states that may have been left-over
from when tcpstream was last opened and closed. However, I do
not believe this fixes your problem in of itself.
unfortunately it doesn't. the project i was hoping to use your classes on has been finished... i ended writing a method to retrieve the socket descriptor (so). And constructing an fstream using it... and then doing stream io through the fstream....