- 论坛徽章:
- 0
|
- ......................................................................
- ......................................................................
- WSADATA wsaData;
- int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
- if ( iResult != NO_ERROR )
- printf("Error at WSAStartup()\n");
- /*---- Create Socket ----*/
- sock = socket (AF_INET, SOCK_STREAM, 0);
- if (sock == INVALID_SOCKET) {
- fprintf (stderr, "can not create socket\n");
- return -2;
- }
- /*---- apply non-block model ----*/
- //fcntl (sock, F_SETFL, O_NONBLOCK | fcntl (sock, F_GETFL)); // linux下设置非阻塞
- //fcntl (sock, F_SETFD, FD_CLOEXEC | fcntl (sock, F_GETFD)); // linux下调用exec时的状态
- memset (&saddr, 0, sizeof (saddr));
- saddr.sin_addr.s_addr = inet_addr (url->host));
- saddr.sin_family = AF_INET; /* host byte order */
- saddr.sin_port = htons (atoi (url->port));/* short, network byte order */
- status = connect (sock, (struct sockaddr *) &saddr, sizeof (struct sockaddr_in));
- ......................................................................
- ......................................................................
复制代码
请问上面这段代码在windows下可以用什么函数来替代fcntl()函数的功能:
- fcntl (sock, F_SETFL, O_NONBLOCK | fcntl (sock, F_GETFL));
- fcntl (sock, F_SETFD, FD_CLOEXEC | fcntl (sock, F_GETFD));
复制代码
[ 本帖最后由 lp5913 于 2008-1-19 17:21 编辑 ] |
|