⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscalls_51.html

📁 Linux系统调用
💻 HTML
字号:
<!-- This HTML file has been created by texi2html 1.29
     from syscalls.texi on 4 June 1994 -->

<TITLE>Syscall specifications of Linux - recv</TITLE>
<P>Go to the <A HREF="syscalls_50.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_50.html">previous</A>, <A HREF="syscalls_52.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_52.html">next</A> section.<P>
<H2><A NAME="SEC51" HREF="syscalls_toc.html#SEC51" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC51">recv, recvfrom and recvmsg</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int recv(int <VAR>s</VAR>, void *<VAR>buf</VAR>, int <VAR>len</VAR>, unsigned int
<VAR>flags</VAR>);</CODE>
<P>
<CODE>int recvfrom(int <VAR>s</VAR>, void *<VAR>buf</VAR>, int <VAR>len</VAR>, unsigned
int <VAR>flags</VAR> struct sockaddr *<VAR>from</VAR>, int *<VAR>fromlen</VAR>);</CODE>
<P>
<CODE>int recvmsg(int <VAR>s</VAR>, struct msghdr *<VAR>msg</VAR>, unsigned int
<VAR>flags</VAR>);</CODE>
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>s</VAR>: [in] the socket to read from.
<P>
<VAR>buf</VAR>: [out] points to a buffer where to put the information read.
<P>
<VAR>len</VAR>: [in] the capacity of the buffer.
<P>
<VAR>flags</VAR>: [in] several options (see description).
<P>
<VAR>from</VAR>: [out] points to an area where to store the peer address. If
<CODE>NULL</CODE>, the peer address is not stored.
<P>
<VAR>fromlen</VAR>: [in out] on entry, points to a number indicating the
capacity of <VAR>from</VAR>. On return, points to an area where to store the
actual length of <VAR>from</VAR>.
<P>
<VAR>msg</VAR>: [out] points to an area where to store the incomming message
header.
<P>
<H3>DESCRIPTION</H3>
<P>
<CODE>recv</CODE> is usually used to receive messages form a
connection-oriented socket. It is equivalent to <VAR>recvfrom</VAR> with
<CODE>from</CODE> set to <CODE>NULL</CODE>.
<P>
<CODE>recvfrom</CODE> and <CODE>recvmsg</CODE> are used for connection-less or
connection-oriented sockets. 
<P>
These calls block if there is no message to receive unless the socket is
non-blocking.
<P>
The <VAR>flags</VAR> parameter may have the following values:
<P>
<DL COMPACT>
<DT><CODE>MSG_OOB</CODE>
<DD>the call will receive out-of-band data instead of in band data.
<P>
<DT><CODE>MSG_PEEK</CODE>
<DD>return the data from the input queue without dequeuing it.
<P>
<DT><CODE>MSG_WAITALL</CODE>
<DD>wait until all data requested is received (<VAR>buf</VAR> is full).
</DL>
<P>
<CODE>recvmsg</CODE> is not yet implemented in Linux.
<P>
<H3>RETURN VALUE</H3>
<P>
On success, the number of bytes received. On error, the call returns -1
and sets <CODE>errno</CODE> to one of the following values:
<P>
<UL>
<LI><CODE>EBADF</CODE>, <CODE>ENOTCONN</CODE>, <CODE>ENOTSOCK</CODE>,
<CODE>EWOULDBLOCK</CODE>, <CODE>EINTR</CODE> or <CODE>EFAULT</CODE>.
</UL>
<P>
<P>Go to the <A HREF="syscalls_50.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_50.html">previous</A>, <A HREF="syscalls_52.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_52.html">next</A> section.<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -