I have a client / server configured, and I want my client to find out if the server has accepted the connection. Otherwise, my client has no idea that he is still waiting to be received. I cannot rely on further communication (protocol specification) to verify this. So, for example, sending the line “Good to go” from the server to the client is not an option. Is there a flag or something that I can check to make sure the server is really receiving? The following is sample code:
...
getaddrinfo(ip, port, &hints, &servinfo);
connect(sockfd, info->ai_addr, info->ai_addrlen);
if (info == NULL) {
printf("connection failure\n");
exit(1);
}
inet_ntop(info->ai_family, get_in_addr((struct sockaddr *)info->ai_addr), ipstring, sizeof(ipstring));
printf("Connected to %s!\n", ipstring);
...
...
pause();
new_fd = accept(sockfd, (struct sockaddr *)&cli_addr, &addr_size);
...
source
share