Portable non GNU TEMP_FAILURE_ENTRY macro

In addition to that subject Here is a portable macro that can be used in place of TEMP_FAILURE_ENTRY, without GNU_SOURCE (took from stackoverflow):

#define CALL_RETRY(retvar, expression) do { \
    retvar = (expression); \
} while (retvar == -1 && errno == EINTR);
/* call example */
char buf[ 4096 ] = "" ;
int retval = -1 ;
/* ... stripped socket initialisation code ... */
CALL_RETRY( br , recv( s , buf , 1024, 0 ) );

In case you receive a “interrupted system calls” signal, there is a chance that this trick may help / guide you to the answer.

#gdb #socket #linux #redhat #EINTR #recv #send

Micro$oft and sockets

Microsoft, have you ever done something as bad as your pesky winsock wrapper around classic sockets ? (correct Berkeley’s error code support for FTW)And your way of always reinventing the wheel at your sauce is FUCKING BORING (Hell yeah, why just use open source? Let’s just add a bunch of proprietary shit inside ==> all those boring WINAPIs which are BTW NOT PORTABLE).

It’s BOOOORING, booooring , booooooooring. (Did I add enough ‘o’ ? Because I think you didn’t add enough WSAshit everywhere)

Now I have to make a proper wrapper because you, as a big company, are not able to follow the standards and make things simple and portable. Micro$oft.

From MSDN: “This means, for example, that checking for errors when the socket and accept functions return should not be done by comparing the return value with –1, or seeing if the value is negative (both common and legal approaches in UNIX). Instead, an application should use the manifest constant INVALID_SOCKET as defined in the Winsock2.h header file.”

Hell yeah, let’s review all our calls to check for a specific Windows code….#ShitNumber1

Also: WSAGetLastError() == WSAEWOULDBLOCK , yeah, yeah, why just use common naming convention when you can add WSAshit everywhere ?

Lets not just talk about the FormatMessage function. Using strerror would have been too much for you to handle, it’s a single line func with a single parameter.