Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#define _OPEN_SYS_SOCK_EXT
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
void tcperror(const char *s);
When a socket call produces an error, the call returns a negative value and the variable errno is set to an error value found in ERRNO.H. The tcperror() call prints a short error message describing the last error that occurred. If s is non-NULL, tcperror() prints the string s followed by a colon, followed by a space, followed by the error message, and terminated with a newline character. If s is NULL or points to a NULL string, only the error message and the newline character are output.
tcperror() returns no values.
The following are examples of the tcperror() call.
if ((s=socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
tcperror("socket()");
exit(2);
}
socket(): not enough storage (ENOMEM)
if ((s=socket(AF_INET, SOCK_DGRAM, 0)) < 0)
tcperror(NULL);
Not enough storage (ENOMEM)