mtcp_recv 3 2017-02-01 "Linux" "mOS Library Functions Manual"
NAME
mtcp_recv - receive a message from a socket
SYNOPSIS
#include <mtcp_api.h> "ssize_t mtcp_recv(mctx_t " mctx ", int " sockid ", char *" buf ", size_t " len ", int " flags );
DESCRIPTION
mtcp_recv () call is normally used only on a
connected socket (see
mtcp_connect() ) and is identical to
mtcp_read() with
flags value set to 0. The function 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_recv()" copies entire data to
"buf" and returns the actual number of bytes that can be used
by the application.
An
mtcp_recv () call takes an additional argument named
"mctx" that represents the per-core mTCP context in an application
(see
mtcp_create_context() for details).
The
"flags" argument to a
"mtcp_recv()" call currently accepts only one non-zero value:
10
"MSG_PEEK" This flag causes the receive operation to return data
from the beginning of the receive queue without removing
that data from the queue. Thus, a subsequent receive call
will return the same data.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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
10
"EBADF" The socket descriptor
"sockid" is invalid.
10
"EINVAL" Invalid argument passed.
10
"ENOTSOCK" The socket referred to by
"sockid" has invalid
"type"
10
"ENOTCONN" Th socket referred to by
"sockid" is in a TCP state that disallows read operations.
10
"EAGAIN" The socket referred to by
"sockid" does not have any available bytes in its buffer
for reading.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
AUTHORS
mOS development team <
[email protected]>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SEE ALSO
mtcp_bind (), mtcp_read (), 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/.
"""""""""""""""""""""""""""""""""""""""""""""""""""""