I'm making a simple client-server application using winsock2 library, but I get a "5" error code when I try to open a socket, but the first error code in the documentation is "6". The thing is, I don't understand what causes the program to exit.
int sockfd;
if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
perror("socket creation failed");
#ifdef OS_WINDOWS
std::cerr << WSAGetLastError() << std::endl;
#endif
exit(EXIT_FAILURE);
}
WSAStartup
before issuing other calls to create sockets. – PaulMcKenzie