DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Intro(SSC-osr5)


Intro -- introduction to socket system calls and error numbers

Syntax

#include <sys/errno.h>

Description

This section describes the SCO OpenServer socket system calls. All of these system calls are accessible from the socket library, libsocket. The link editor ld(CP) and the C compiler cc(CP) search this library when the -lsocket option is specified. Most of these calls have one or more error returns, and some of the error codes are socket specfic. An error condition is indicated by an otherwise impossible return value. This is almost always -1; the individual descriptions specify the details. Note that a number of system calls overload the meanings of these error numbers, and that the meanings must be interpreted according to the type and circumstances of the call.

As with normal arguments, all return codes and values from functions are of type integer unless otherwise noted. An error number that is not cleared on successful calls is also made available in the errno external variable. Thus errno should be tested only after an error has occurred.

The following is a complete list of the socket errors and their names as given in <sys/errno.h>. See Intro(S-osr5) for a more comprehensive list of error codes.


63
ENOBUFS
No buffer space available

An operation on a socket or pipe was not performed because the system lacked sufficient buffer space or because a queue was full. ENOBUFS is defined to have the same value as ENOSR.


90
TCPERR
The starting value of socket related error codes.

TCPERR+0
EWOULDBLOCK
Operation would block

An operation that would cause a process to block was attempted on an object in non-blocking mode (see fcntl(S-osr5)).


TCPERR+1
EINPROGRESS
Operation now in progress

An operation that takes a long time to complete (such as a connect(SSC-osr5)) was attempted on a non-blocking object (see fcntl(S-osr5)).


TCPERR+2
EALREADY
Operation already in progress

An operation was attempted on a non-blocking object that already had an operation in progress.


TCPERR+3
ENOTSOCK
Socket operation on non-socket.

TCPERR+4
EDESTADDRREQ
Destination address required.

A required address was omitted from an operation on a socket.


TCPERR+5
EMSGSIZE
Message too long.

A message sent on a socket was larger than the internal message buffer or some other network limit.


TCPERR+6
EPROTOTYPE
Protocol wrong type for socket.

A protocol was specified that does not support the semantics of the socket type requested. For example, you cannot use the ARPA Internet UDP protocol with type SOCK_STREAM.


TCPERR+7
EPROTONOSUPPORT
Protocol not supported

The protocol has not been configured into the system or no implementation for it exists.


TCPERR+8
ESOCKTNOSUPPORT
Socket type not supported

The support for the socket type has not been configured into the system or no implementation for it exists.


TCPERR+9
EOPNOTSUPP
Operation not supported on socket

For example, trying to accept a connection on a datagram socket.


TCPERR+10
EPFNOSUPPORT
Protocol family not supported

The protocol family has not been configured into the system or no implementation for it exists.


TCPERR+11
EAFNOSUPPORT
Address family not supported by protocol family

An address incompatible with the requested protocol was used. For example, you shouldn't necessarily expect to be able to useNS addresses with ARPA Internet protocols.


TCPERR+12
EADDRINUSE
Address already in use

Only one usage of each address is normally permitted.


TCPERR+13
EADDRNOTAVAIL
Can't assign requested address

Normally results from an attempt to create a socket with an address not on this machine.


TCPERR+14
ENETDOWN
Network is down

A socket operation encountered a dead network.


TCPERR+15
ENETUNREACH
Network is unreachable

A socket operation was attempted to an unreachable network.


TCPERR+16
ENETRESET
Network dropped connection on reset

The host you were connected to crashed and rebooted.


TCPERR+17
ECONNABORTED
Software caused connection abort

A connection abort was caused internal to your host machine.


TCPERR+18
ECONNRESET
Connection reset by peer

A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or a reboot.


TCPERR+19
unused

TCPERR+20
EISCONN
Socket is already connected

A connect request was made on an already connected socket; or, a sendto or sendmsg request on a connected socket specified a destination when already connected.


TCPERR+21
ENOTCONN
Socket is not connected

A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket) no address was supplied.


TCPERR+22
ESHUTDOWN
Can't send after socket shutdown

A request to send data was disallowed because the socket had already been shut down with a previous shutdown(SSC-osr5) call.


TCPERR+23
unused

TCPERR+24
ETIMEDOUT
Connection timed out

A connect or send request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.)


TCPERR+25
ECONNREFUSED
Connection refused

No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.


TCPERR+26
EHOSTDOWN
Host is down

A socket operation failed because the destination host was down.


TCPERR+27
EHOSTUNREACH
Host is unreachable

A socket operation was attempted to an unreachable host.


TCPERR+28
ENOPROTOOPT
Option not supported by protocol

A bad option or level was specified in a getsockopt(SSC-osr5) or setsockopt(SSC-osr5) call.

Files

/usr/lib/libsocket.a

Definitions


Socket descriptor
An integer assigned by the system when a socket is referenced by dup(S-osr5), or when a socket is created by socket(SSC-osr5), which uniquely identifies an access path to that socket from a given process or any of its children.

Sockets and address families
A socket is an endpoint for communication between processes. Each socket has queues for sending and receiving data.

Sockets are typed according to their communications properties. These properties include whether messages sent and received at a socket require the name of the partner, whether communication is reliable, the format used in naming message recipients, etc.

Each instance of the system supports some collection of socket types; consult socket(SSC-osr5) for more information about the types available and their properties.

Each instance of the system supports some number of sets of communications protocols. Each protocol set supports addresses of a certain format. An Address Family is the set of addresses for a specific group of protocols. Each socket has an address chosen from the address family in which the socket was created.

List of functions

Name Appears on Page Description
accept accept(SSC-osr5) accept a connection on a socket
bind bind(SSC-osr5) bind a name to a socket
connect connect(SSC-osr5) initiate a connection on a socket
getpeername getpeername(SSC-osr5) get name of connected peer
getsockname getsockname(SSC-osr5) get socket name
getsockopt getsockopt(SSC-osr5) get options on sockets
gettimeofday gettimeofday(SSC-osr5) get date and time
listen listen(SSC-osr5) listen for connections on a socket
recv recv(SSC-osr5) receive a message from a connected socket
recvfrom recv(SSC-osr5) receive a message from a socket
recvmsg recv(SSC-osr5) receive a message from a socket
send send(SSC-osr5) send a message to a connected socket
sendmsg send(SSC-osr5) send a message to a socket
sendto send(SSC-osr5) send a message to a socket
setsockopt getsockopt(SSC-osr5) set options on sockets
settimeofday gettimeofday(SSC-osr5) set date and time
shutdown shutdown(SSC-osr5) shut down part of a full-duplex connection
socket socket(SSC-osr5) create an endpoint for communication
socketpair socketpair(SSC-osr5) create a pair of connected sockets

 +-------------+----------------------+--------------------------------------------+
 |Name         | Appears on Page      | Description                                |
 +-------------+----------------------+--------------------------------------------+
 |accept       |  accept(SSC-osr5)         | accept a connection on a socket            |
 +-------------+----------------------+--------------------------------------------+
 |bind         |  bind(SSC-osr5)           | bind a name to a socket                    |
 +-------------+----------------------+--------------------------------------------+
 |connect      |  connect(SSC-osr5)        | initiate a connection on a socket          |
 +-------------+----------------------+--------------------------------------------+
 |getpeername  |  getpeername(SSC-osr5)    | get name of connected peer                 |
 +-------------+----------------------+--------------------------------------------+
 |getsockname  |  getsockname(SSC-osr5)    | get socket name                            |
 +-------------+----------------------+--------------------------------------------+
 |getsockopt   |  getsockopt(SSC-osr5)     | get options on sockets                     |
 +-------------+----------------------+--------------------------------------------+
 |gettimeofday |  gettimeofday(SSC-osr5)   | get date and time                          |
 +-------------+----------------------+--------------------------------------------+
 |listen       |  listen(SSC-osr5)         | listen for connections on a socket         |
 +-------------+----------------------+--------------------------------------------+
 |recv         |  recv(SSC-osr5)           | receive a message from a connected socket  |
 +-------------+----------------------+--------------------------------------------+
 |recvfrom     |  recv(SSC-osr5)           | receive a message from a socket            |
 +-------------+----------------------+--------------------------------------------+
 |recvmsg      |  recv(SSC-osr5)           | receive a message from a socket            |
 +-------------+----------------------+--------------------------------------------+
 |send         |  send(SSC-osr5)           | send a message to a connected socket       |
 +-------------+----------------------+--------------------------------------------+
 |sendmsg      |  send(SSC-osr5)           | send a message to a socket                 |
 +-------------+----------------------+--------------------------------------------+
 |sendto       |  send(SSC-osr5)           | send a message to a socket                 |
 +-------------+----------------------+--------------------------------------------+
 |setsockopt   |  getsockopt(SSC-osr5)     | set options on sockets                     |
 +-------------+----------------------+--------------------------------------------+
 |settimeofday |  gettimeofday(SSC-osr5)   | set date and time                          |
 +-------------+----------------------+--------------------------------------------+
 |shutdown     |  shutdown(SSC-osr5)       | shut down part of a full-duplex connection |
 +-------------+----------------------+--------------------------------------------+
 |socket       |  socket(SSC-osr5)         | create an endpoint for communication       |
 +-------------+----------------------+--------------------------------------------+
 |socketpair   |  socketpair(SSC-osr5)     | create a pair of connected sockets         |
 +-------------+----------------------+--------------------------------------------+

See also

Intro(S-osr5), perror(S-osr5)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005