linux socket编程

获取socket options

include  <sys/socket.h>
include <sys/time.h>
include <stdio.h>
int main() {
     int sock = socket(AF_INET, SOCK_STREAM, 0);
    struct timeval tv;
    size_t len = sizeof(tv);
    getsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, (socklen_t*)&len);
    printf(“timeout: %d, %d\n”, tv.tv_sec, tv.tv_usec);
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *