iOS - Ping with timeout

前端 未结 2 2064
暖寄归人
暖寄归人 2020-12-02 16:06

I\'m using Apple\'s \"Simple Ping\" example and it has almost all features that I need, but I don\'t know where I can set timeout of each packet. It seems that it isn\'t pos

2条回答
  •  一整个雨季
    2020-12-02 16:41

    for example:

    tv.tv_sec = 0;

    tv.tv_usec = 1000;

    setsockopt(recv_sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));

    setsockopt(send_sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,sizeof(struct timeval));

    for additional options:

    http://developer.apple.com/library/ios/#documentation/system/conceptual/manpages_iphoneos/man2/setsockopt.2.html

提交回复
热议问题