z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


send()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The send() call sends datagrams on the socket with descriptor s. The send() call applies to all connected sockets.

If buffer space is not available to hold the socket data to be transmitted, and the socket is in blocking mode, send() blocks the caller until more buffer space becomes available. If the socket is in nonblocking mode, send() returns a -1 and sets errno to EWOULDBLOCK. See fcntl() or ioctl() to set nonblocking mode. See select() for additional information.

For datagram sockets, this call sends the entire datagram, providing the datagram can fit into the TCP/IP buffers. Stream sockets act like streams of information with no boundaries separating data. For example, if an application wants to send 1000 bytes, each call to this function can send 1 byte, or 10 bytes, or the entire 1000 bytes. Therefore, applications using stream sockets should place this call in a loop and call this function until all data has been sent.

#include <manifest.h>
#include <bsdtypes.h>
#include <socket.h>
 
int send(int s, char *msg, int len, int flags)
Parameter
Description
s
Socket descriptor.
msg
Points to the buffer containing the message to transmit.
len
Length of the message pointed to by msg.
flags
Set the flags parameter by specifying one or more of the following flags. If more than one flag is specified, the logical OR operator (|) must be used to separate them. Setting this parameter is supported only for sockets in the AF_INET domain. Setting these flags is not supported in the AF_IUCV domain.
MSG_OOB
Sends out-of-band data on sockets that support this function. Only SOCK_STREAM sockets created in the AF_INET address family support out-of-band data.
MSG_DONTROUTE
The MSG_DONTROUTE option is turned on for the duration of the operation. This is usually used only by diagnostic or routing programs.

Return values

No indication of failure to deliver is implicit in a send() routine. The value -1 indicates locally detected errors. Errno identifies the specific error.
Errno
Description
EBADF
Indicates that s is not a valid socket descriptor.
EFAULT
Using the msg and len parameters would result in an attempt to access storage outside the caller address space.
ENOBUFS
Buffer space is not available to send the message.
EWOULDBLOCK
Indicates that s is in nonblocking mode and there is not enough space in TCP⁄IP to accept the data.

Related calls

connect(), fcntl(), getsockopt(), ioctl(), read(), readv(), recv(), recvfrom(), recvmsg(), select(), selectex(), sendmsg(), sendto(), socket(), write(), writev()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014