Without:
- MFC
- ATL
Using pure C++, WSAGetLastError() returns 10014 - Bad address
- What I'm I missing/doing wrong?
Code illustration:
sockaddr_in sin;
SOCKET server;
if ((server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == SOCKET_ERROR)
{
cerr << "Error: socket() return value == SOCKET_ERROR" << endl;
WSACleanup();
exit (EXIT_FAILURE);
}
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(1234); //random port
if(bind(server, (sockaddr *)&sin, sizeof(sin) == SOCKET_ERROR))
{
wError = WSAGetLastError();
cerr << "Error: bin() return value == SOCKET_ERROR\n"
"Details: " << wError << endl;
WSACleanup();
exit (EXIT_FAILURE);
}