next up previous contents index
Next: Part III: Function Libraries Up: 8.2 oskit_socket: Socket Interface Previous: 8.2.10 recvfromrecvmsg: receive

8.2.11 sendto, sendmsg: send a message from a socket

 

SYNOPSIS

#include <oskit/net/socket.h>

oskit_error_t oskit_socket_sendto(oskit_socket_t *s, const void *buf, oskit_size_t len, oskit_u32_t flags, const struct oskit_sockaddr *to, oskit_size_t tolen, [out] oskit_size_t *retval);

oskit_error_t oskit_socket_sendmsg(oskit_socket_t *s, const struct oskit_msghdr *msg, oskit_u32_t flags, [out] oskit_size_t *retval);

DESCRIPTION

sendto, sendmsg are used to transmit a message to another socket. The C library send may be implemented by passing a NULL to parameter. It may be used only when the socket is in a connected state, while sendto and sendmsg may generally be used at any time.

Send will block if no messages space is available at the socket to hold the message to be transmitted.

PARAMETERS

s
The socket from which the message is to be sent.

buf

len
len gives the length of the message. If the message is too long to pass atomically through the underlying protocol, the error OSKIT_EMSGSIZE is returned, and the message is not transmitted.

flags
The flags parameter may include one or more of the following:

OSKIT_MSG_OOB process out-of-band data
OSKIT_MSG_PEEK peek at incoming message
OSKIT_MSG_DONTROUTE bypass routing, use direct interface
OSKIT_MSG_EOR data completes record
OSKIT_MSG_EOF data completes transaction

The flag OSKIT_MSG_OOB is used to send ``out-of-band'' data on sockets that support this notion (e.g. OSKIT_SOCK_STREAM); the underlying protocol must also support ``out-of-band'' data. OSKIT_MSG_EOR is used to indicate a record mark for protocols which support the concept. OSKIT_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 implemented for OSKIT_SOCK_STREAM sockets in the OSKIT_PF_INET protocol family.

to, tolen
The address of the target is given by to with tolen specifying its size.

msg
See recvmsg for a description of the oskit_msghdr structure.

retval
Upon return *retval contains the number of characters sent.

RETURNS

Returns 0 on success. No indication of failure to deliver is implicit in a send. Locally detected errors are indicated by an error code specified in <oskit/error.h>.

next up previous contents index
Next: Part III: Function Libraries Up: 8.2 oskit_socket: Socket Interface Previous: 8.2.10 recvfromrecvmsg: receive

University of Utah Flux Research Group