Getter Winsock programming problem

zhaozj2021-02-16  51

The following is a code of the TCP / IP server program in the "Windows Network Programming" book: #include

void main (void) {WSADATA wsaData; SOCKET ListeningSocket, NewConnection; SOCKADDR_IN ServerAddr, ClientAddr; int Port = 5150; WSAStartup (MAKEWORD (2,2), & wsaData); ListeningSocket = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); ServerAddr.sin_family = AF_INET; ServerAddr.sin_port = htons (Port); ServerAddr.sin_addr.s_addr = htonl (INADDR_ANY); bind (ListeningSocket, (SOCKADDR *) & ServerAddr, sizeof (ServerAddr)); listen (ListeningSocket, 5); int ClientAddrLen; NewConnection = Accept (Listeningsocket, (SockAddr *) & clientaddr, & clientaddrlen; CloseSocket (Newconnection); CloseSocket (Listeningsocket); WSACLANUP (); The code should be blocked when executing accept (), but I didn't block when I executed the code. May i know what is this all about?

转载请注明原文地址:https://www.9cbs.com/read-20754.html

New Post(0)