Menu

Socket - send, receive, timeouts, etc.

Help
2001-04-13
2001-04-13
  • Peter Dotchev

    Peter Dotchev - 2001-04-13

    I have dicsovered this project recently and I think it's really a *great* idea to have a portable class library covering many general issues.

    And now my questions concerning CC++:
    1. I thought it naturally for a sockect class to have Send and Receive methods.
    How could I use a socket class from CC++ (not a stream) to send and receive data ?

    2. I didn't find out how to specify send/receive timeouts.
    Why doesn't CC++ employ SO_RCVTIMEO/SO_SNDTIMEO where available ?

    3. Why there are no dedicated exception classes ?
    In most places I see code like this "throw(this)".
    I thought it would be nice to have a separate tree of exceptio classes. exception class from STL could serve as root.
    I'd like to write code like this:
    tcp.setRecvTimeout(1000);
    try {
       ...
       tcp >> i;
       ...
    }
    catch(SocketException &e) {
       if (e.code() == ETIMEDOUT)
          // handle timeout
       ...
    }

    4. In general I think it would be be very helpful to have a FAQ treating common (stupid) questions like mine. :)

    regards,
    nomadik

     
    • spacebat

      spacebat - 2001-04-13

      I agree...

      Here's a way you can check the send/recv status of a socket without blocking (second arg is the timeout in ms):

          pend = usock_b.isPending( SOCKET_PENDING_INPUT, 5000 );

      Check out isPending().

       

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.