Menu

recv?

Help
Dan Nguyen
2000-03-24
2000-03-28
  • Dan Nguyen

    Dan Nguyen - 2000-03-24

    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.

     
    • David Sugar

      David Sugar - 2000-03-24

      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?

       
      • Dan Nguyen

        Dan Nguyen - 2000-03-24

        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.

         
        • David Sugar

          David Sugar - 2000-03-24

          I will try to create a test case app for this, and see what I find playing with it.

           
        • David Sugar

          David Sugar - 2000-03-24

          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.

           
          • Dan Nguyen

            Dan Nguyen - 2000-03-24

            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.

             
            • Dan Nguyen

              Dan Nguyen - 2000-03-24

              in TCPStream::undeflow() gptr() is NULL so it's returning EOF

               
              • David Sugar

                David Sugar - 2000-03-24

                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()??

                 
                • Dan Nguyen

                  Dan Nguyen - 2000-03-24

                  something is going wrong with the iostream library... it wants to reset the read_ptr when it attempts to read.

                   
                  • David Sugar

                    David Sugar - 2000-03-24

                    hmm...when I get a chance to use a Solaris box, I will want to look into this more myself.  Very odd.

                     
                  • David Sugar

                    David Sugar - 2000-03-27

                    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.

                     
                    • Dan Nguyen

                      Dan Nguyen - 2000-03-27

                      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.

                       
                      • David Sugar

                        David Sugar - 2000-03-27

                        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).

                         
                      • David Sugar

                        David Sugar - 2000-03-28

                        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.

                         
                        • Dan Nguyen

                          Dan Nguyen - 2000-03-28

                          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....

                           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.