[fpc-pascal] Translating from error numbers to symbolic name

Marco van de Voort marcov at stack.nl
Sat Aug 4 00:24:41 CEST 2012

In our previous episode, Mark Morgan Lloyd said:
> When using a function like fpAccept on a non-blocking socket, in some 
> cases -1 is returned with a documented (Linux kernel) error code of 
> EAGAIN. Should I be looking for this in errno or SocketError?

Socketerror is more portable, but on *nix errno will work too.
> When I've retrieved a numeric code from errno or SocketError, is there a 
> way of converting it to a concise literal such as 'EAGAIN'?

See errors unit.

> I want the 
> log to report that accept() has failed with EAGAIN, rather than having 
> explanatory text that doesn't match the kernel documentation.

EAGAIN generally means that you should try again. So repeat until
  until (res<>-1) or ((err<>ESysEINTR) and (err<>ESysEAgain));
it is a workaround against potential deadlock between userland and kernel
iirc. Retrying means it can simple work.

More information about the fpc-pascal mailing list