Using the flag MSG_ERRQUEUE, it is possible on some sockets to receive error information via ancillary messages.