Category : winsock2

I have put together a method based on Windows’ winsock2.h docs: SOCKET SocketClass::create() { struct addrinfo* result = NULL, *ptr = NULL, hints; ZeroMemory(&hints, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; //random error DWORD retrieved = getaddrinfo("https://stackoverflow.com", "27015", &hints, &result); std::cout << retrieved; if (retrieved != 0) { return 1; } SOCKET ..

Read more

It is necessary to modify the unencrypted data that the server sends before it is received by the client. int WSAAPI __WSARecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) { int result = _WSARecv(s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine); // The original WSARecv must be called to fill ..

Read more

I was experimenting with Winsock2 at the moment, and got a warning that inet_ntoa() is deprecated and that I should use inet_pton(). I tried it, but it was little endian, so the whole string that was saved in the buffer was "wrong". I’m guessing inet_ntoa() is big endian? And I could only use inet_pton() with ..

Read more