The close() call shuts down transmission, given the original socket descriptor obtained from the socket() call. Some server applications close immediately after receiving client data, while others wait for additional connections. To compile on Windows, you must call the Winsock closesocket() instead of close().

#ifdef _WIN32
     return closesocket(sockfd);
#else
     return close(sockfd);
#endif