我有一個win32應用程序項目。但是當程序到達像 這樣的位置時,假設new_socket = accept(socket,(sockaddr *)& client,& c); 它卡住了。在這類腳本中,它使我無法使用任何其他按鈕,文件菜單等是任何能告訴我什麼是錯誤的以及如何修復它的人。SendMessage()到win32應用程序vC++
這是它卡住的功能:
void server(){
WSADATA wsa;
SOCKET server_socket, client_socket;
struct sockaddr_in server, client;
int c, yes=1;
int sent_length = 1;
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0) printf("Failed. Error Code : %d",WSAGetLastError());
if((server_socket = socket(AF_INET , SOCK_STREAM , 0)) == INVALID_SOCKET){
printf("Could not create socket : %d" , WSAGetLastError());
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = 0;
server.sin_port = htons(8080);
memset(&(server.sin_zero), '\0', 8);
bind(server_socket ,(struct sockaddr *)&server , sizeof(server));
listen(server_socket, 3);
c = sizeof(struct sockaddr_in);
while(1){
client_socket = accept(server_socket,(struct sockaddr *)&client, &c);
send(client_socket, "Hello, World", 13, 0);
}
WSACleanup();
}
標題和問題之間的隱藏鏈接在哪裏? – IInspectable 2015-04-03 16:26:15