mtcp_read

NAME

mtcp_read − read bytestream from an mTCP socket

SYNOPSIS

#include <mtcp_api.h>

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

DESCRIPTION

mtcp_read() can be used to read up to len number of bytes from mTCP socket via socket descriptor sockid into the buffer starting at buf. It is the responsibility of the user to allocate memory for buf array.

For cases when the total number of buffered unread bytes in the socket are less than len, mtcp_read() copies entire data to buf and returns the actual number of bytes that can be used by the application.

An mtcp_read() 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 read is returned. It is not an error if this number is smaller than the number of bytes requested; this may happen when the socket has fewer number of bytes buffered at that moment. On all errors, -1 is returned and errno is set appropriately.

ERRORS

EBADF

The socket descriptor sockid is invalid.

ENOTSOCK

The socket referred to by sockid has invalid type

ENOTCONN

Th socket referred to by sockid is in a TCP state that disallows read operations.

EAGAIN

The socket referred to by sockid does not have any available bytes in its buffer for reading.

AUTHORS

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

SEE ALSO

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

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/.