mtcp_write

NAME

mtcp_write − send bytestream to an mTCP socket

SYNOPSIS

#include <mtcp_api.h>

ssize_t mtcp_write(mctx_t mctx, int sockid, char *buf, size_t len);

DESCRIPTION

mtcp_write() sends up to len number of bytes from the buffer that is being pointed by buf. The bytestream is sent to the mTCP socket using the sockid descriptor.

An mtcp_write() function call may write less number of bytes than len if there is insufficient space in the write buffer of the socket. In such a case, the return value is considered the actual number of bytes successfully written.

mtcp_write() call takes an additional argument named mctx that represents the per-core mTCP context in an application (see mtcp_create_context() for details).

RETURN VALUE

On success, the number of bytes dispatched via the socket are returned. The number of bytes sent can be less than count if there is insufficient space in the write buffer of the socket. On error, -1 is returned and errno is set appropriately.

ERRORS

EAGAIN

The write buffer of the socket is currently full. The user should call the write function again once the write buffer has space available.

EBADF

sockid is not a valid socket descriptor for writing.

ENOTCONN

The underlying connection is not in a TCP state that allows data transmission (i.e. the TCP flow is neither in ESTABLISHED or CLOSE_WAIT state).

ENOTSOCK

The socket referred to by sockid is not valid.

AUTHORS

mOS development team <mtcp-user@list.ndsl.kaist.edu>

SEE ALSO

mtcp_bind(), mtcp_listen(), mtcp_accept(), mtcp_connect(), mtcp_read(), mtcp_socket()

COLOPHON

This page is part of mOS release 0.3 docs section. A description of the project, and information about reporting bugs, can be found at http://mos.kaist.edu/.