Paste the following code into a new project, build it, run it, and paste the output of the program here.
#pragma comment( lib, "Ws2_32.lib" )
#include <iostream>
#include <windows.h>
int main() {
int error = 0;
WSADATA data;
error = WSAStartup( MAKEWORD( 2, 2 ), &data );
if( error ) {
std::cout << "WSAStartup() failed: " << error << "\n";
return -1;
}
SOCKET s = socket( PF_INET, SOCK_STREAM, 0 );
if( s == INVALID_SOCKET ) {
std::cout << "socket() failed: " << WSAGetLastError() << "\n";
return -1;
}
u_long block = 1;
error = ioctlsocket( s, FIONBIO, &block );
if( error == SOCKET_ERROR ) {
std::cout << "ioctlsocket() failed: " << WSAGetLastError() << "\n";
return -1;
}
int no_delay = 1;
error = setsockopt( s, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>( &no_delay ), sizeof( no_delay ) );
if( error == SOCKET_ERROR ) {
std::cout << "setsockopt() failed: " << WSAGetLastError() << "\n";
return -1;
}
error = closesocket( s );
if( error == SOCKET_ERROR ) {
std::cout << "closesocket() failed: " << WSAGetLastError() << "\n";
return -1;
}
error = WSACleanup();
if( error == SOCKET_ERROR ) {
std::cout << "WSACleanup() failed: " << WSAGetLastError() << "\n";
return -1;
}
std::cout << "Everything completed successfully.\n";
return 0;
}