Hello!

I am having trouble using {g,s}etsockopt(SO_RCVTIMEO).  Consider the following 
small test program.
I expect to retrieve the value of 1 second via getsockopt call, I expect the 
following output:
tv_sec=1, tv_usec=0
But I actually get
tv_sec=0, tv_usec=0

What am I missing? 

Thanks!

PS: on Linux it works as I expect.


#include <err.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>

int main() {
    struct timeval tv;
    int fd;
    tv.tv_sec=1;
    tv.tv_usec=0;
    fd = socket(PF_UNIX, SOCK_STREAM, 0);
    if (fd < 0)
        err(1, "socket");
    socklen_t len = sizeof(struct timeval);
    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, len))
        err(1, "setsockopt");
    if (getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, &len))
        err(1, "getsockopt");
    printf("tv_sec=%ld, tv_usec=%ld\n", tv.tv_sec, tv.tv_usec);
}

_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to