//accept()函数原型 WINSOCK_API_LINKAGE _Must_inspect_result_ SOCKET WSAAPI accept( _In_ SOCKET s, //用来标识服务器端套接字(也就是listen函数中设置为监听状态的套接字) _Out_writes_bytes_opt_(*addrlen) struct sockaddr FAR * addr, //用来保存客户端套接字对应的信息(包括客户端IP和端口信息等) _Inout_opt_ int FAR * addrlen //保存客户端套接字信息所需的空间长度 ); //返回值对应客户端套接字标识
//accept()示例 SOCKADDR_IN addr; int len = sizeof(SOCKADDR_IN); SOCKET socket_client = accept(socket_server, (sockaddr*)&addr,&len);