sock_errno: Return the error code set by a socket call

The sock_errno socket function returns the error code set by a socket call.

Last updated

Added for PUT00.

Format

#include  <sys/socket.h>
int       sock_errno(void);

Normal return

A nonnegative error code is returned.

Error return

None.

Programming considerations

None.

Examples

The following example prints out the socket error number if an error occurs in the socket function.
#include <sys/socket.h>
⋮
int rc;
int server_sock;
⋮
server_sock = socket(AF_INET, SOCK_STREAM, 0);
if (server_sock == -1)
{
  printf("Error in socket - %d\n",sock_errno());
  exit(0);
}

Related information

See z/TPF Transmission Control Protocol/Internet Protocol for information about z/TPF TCP/IP support.