要预防此类攻击,接受连接的线程应该不时地通过调用getsockopt()函数(选项参数为SO_CONNECT_TIME)来检查AcceptEx()里守候的套接字。
To prevent malicious attacks or stale connections, the accepting thread should occasionally check the sockets outstanding in AcceptEx by calling getsockopt and SO_CONNECT_TIME.
控制现在返回到connect函数,该函数处于睡眠状态,直到协议层唤醒—指示连接现在是ESTABLISHED,或套接字上存在错误。
The control now returns to the connect function, which sleeps until the protocol layer wakes up-indicating that the connection is now ESTABLISHED or that there has been an error on the socket.
如果存在任何套接字错误,则函数返回,并继续从队列拾取新的连接并调用soaccept。
If there were any socket errors, the function returns, and it proceeds further by picking up the new connection from the queue and calls soaccept.
从soconnect返回时,connect函数进入睡眠状体,直到协议层将其唤醒,并指示连接是ESTABLISHED或套接字上存在错误。
Upon returning from soconnect , the connect function issues a sleep until the protocol layer wakes it up, indicating that the connection is ESTABLISHED or there has been some error on the socket.
main:主函数创建用来监听连接的套接字,然后创建accept的回调函数以便通过事件处理函数处理每个连接。
Main : the main function creates the socket to be used for listening to connections, and then creates the callback for accept to handle each connection through the event handler.
soo_close()仅调用 so_close()函数,该函数首先检查要关闭的套接字是否为侦听套接字(正在接收传入连接的套接字)。
The soo_close() simply calls the so_close() function, which first checks if the socket to be closed is a listening socket (socket that's accepting incoming connections).
soo_close()仅调用 so_close()函数,该函数首先检查要关闭的套接字是否为侦听套接字(正在接收传入连接的套接字)。
The soo_close() simply calls the so_close() function, which first checks if the socket to be closed is a listening socket (socket that's accepting incoming connections).
应用推荐