Announcement

Collapse
No announcement yet.

getsockopt

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • getsockopt

    Hi all
    Please help I am a little confused (again). according to what I have read the following should work.

    struct timeval time;
    int time_size;
    ...
    ipsocket = socket(..);

    ..
    time_size = sizeof(time);
    if(getsockopt(ipsocket,SOL_SOCKET,SO_SNDTIMEO,(cha r*)&time,&time_size) == 0)
    sprintf(buffer,"\r\nSO_SNDTIMEO = %d . %d (%d)", time.tv_sec, time.tv_usec, time_size);

    contents of buffer = "SO_RCVTIMEO = -1 . -1 (-1)"

    What am I doning wrong?

    Many Thanks
    Carl

  • #2
    getsockopt

    Hi I found part of the problem
    I misused sprintf by passing a long into it - Sorry!
    however the function still does not return as expected --
    The length (optlen) parameter returns 4! shouldn't this be 8?

    struct timeval {
    long tv_sec; /*!< seconds */
    long tv_usec; /*!< microseconds */
    };

    Many Thanks
    Carl

    Comment


    • #3
      Okay, I checked the source code for this function, and it is currently returning the size of the struct timeval pointer, not the size of the data in the struct timeval itself.

      I need to confer with the engineering team to be sure this was intended. I will post back with what I learn.

      In any case, thanks for bringing this to our attention!

      Comment

      Working...
      X