Example #3Source File: base_socket_connection.py From boofuzz with GNU General Public License v2.0 5 votes def open(self): """ Opens connection to the target. Make sure to call close! Returns: None """ self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDTIMEO, _seconds_to_sockopt_...
它可以应用于TCP、UDP等套接字。 举个例子,假设我们有一个服务器端的TCP套接字,需要在接收数据时设置超时时间为5秒钟。我们可以使用以下代码来设置SO_RCVTIMEO选项: intsockfd=socket(AF_INET,SOCK_STREAM,0); // 设置超时时间为5秒 structtimeval timeout; timeout.tv_sec=5; timeout.tv_usec=0; setsocko...