Sockets Programming Interfaces
3-29
Sockets and Stream IO API
For a datagram type socket, the send operation always copies one packet’s
worth of data. If the buffer is too long to hold the entire packet an error code
of EMSGSIZE is returned.
If there is not transmit buffer space available on a stream type socket, the func-
tion waits for space to become available, unless the socket is non-blocking.
The function normally transmits all the specified data.
The select call (fdSelect()) may be used to determine when the socket is “able
to write”.
The flags argument to a send() call is formed by combining one or more of the
following flags:
MSG_OOB
used to send out-of-band data on sockets that
support this notion (e.g., SOCK_STREAM); the
underlying protocol must also support out-of-band
data.
MSG_EOR
used to indicate a record mark for protocols that
support the concept.
MSG_EOF
requests that the sender side of a socket be shut
down, and that an appropriate indication be sent at
the end of the specified data; this flag is only im-
plemented for SOCK_STREAM sockets in the
PF_INET protocol family, and is used to implement
Transaction TCP.
MSG_DONTROUTE
specifies that the packet should not be routed, but
sent only using the ARP table entries.
Transmit Data on a Socket to Designated Destination
sendto
Syntax
int sendto( int s, void *pbuf, int size, int flags, PSA pName, int len );
Parameter(s)
s
Socket
pbuf
Data buffer holding data to transmit
size
Size of data
flags
Option flags
pName
Pointer to name (address) of destination
len
Size of data pointed to by pName
Return Value
If it succeeds, the function returns the number of bytes sent. Otherwise, a value
of –1 is returned and the function fdError() can be called to determine the error:
EBADF
The file descriptor (socket) is invalid.
ENOTSOCK
The file descriptor does not reference a socket.