1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" Modified Sat Jul 24 01:15:33 1993 by Rik Faith <faith@cs.unc.edu>
33 .\" Modified Tue Oct 22 17:55:49 1996 by Eric S. Raymond <esr@thyrsus.com>
34 .\" Modified Oct 1998 by Andi Kleen
35 .\" 中文版 Copyright (c) 2002 byeyear 和 www.linuxforum.net
37 .TH SEND 2 "July 1999" "Linux Man Page" "Linux Programmer's Manual"
39 send, sendto, sendmsg \- 从套接字发送消息
41 .B #include <sys/types.h>
43 .B #include <sys/socket.h>
45 .BI "int send(int " s ", const void *" msg ", size_t " len ","
48 .BI "int sendto(int " s ", const void *" msg ", size_t " len ","
49 .BI "int " flags ", const struct sockaddr *" to ", socklen_t " tolen );
51 .BI "int sendmsg(int " s ", const struct msghdr *" msg ","
81 当要发送的消息长度大于套接字当前可用缓冲区时,
83 将阻塞,除非在套接字上设置了非阻塞式输入输出模式.
95 .\" XXX document MSG_PROXY
109 在送出分组时不使用网关.只有直接连接在网络上的主机
110 才能接收到数据.这个标志通常仅用于诊断和路由程序.
111 可路由的协议族才能使用这个标志;包套接字不可以.
114 使用非阻塞式操作;如果操作需要阻塞,将返回
130 .BR MSG_CONFIRM " (仅用于Linux 2.3以上版本)"
131 通知链路层发生了转发过程:得到了另一端的成功应答.
132 如果链路层没有收到通知,它将按照常规探测网络上的相邻
138 类型的套接字,且仅对IPv4和IPv6有效.详情参见
151 void * msg_name; /*地址选项*/
152 socklen_t msg_namelen; /*地址长度*/
153 struct iovec * msg_iov; /*消息数组*/
154 size_t msg_iovlen; /*msg_iov中的元素个数*/
155 void * msg_control; /*辅助信息,见下文*/
156 socklen_t msg_controllen; /*辅助数据缓冲区长度*/
157 int msg_flags; /*接收消息标志*/
167 成员发送任何控制信息.内核所能处理的最大控制消息缓冲区长度由
168 .B net.core.optmem_max
174 其中一些是套接字层产生的标准错误.其他的是下层协议模块产生的;参见
191 .BR EAGAIN "或者" EWOULDBLOCK
192 套接字设置为非阻塞式,但所请求的操作需要阻塞.
195 网络接口输出队列已满.这通常表明接口已停止发送,也有可能是
196 暂时性的拥挤(这不会发生在linux下,当设备队列溢出时数据报
209 连接套接字的本地端已关闭.这种情况下进程还会接收到
214 4.4BSD,SVr4,POSIX1003.1g草案(这些系统调用首次出现于4.2BSD).
218 上面给出的函数原型遵循Single Unix Specification,
221 参数在BSD4.*中是`int',但在libc4和libc5中是`unsigned int';
224 在BSD4.*和libc4中是`int',但在libc5中是'size_t';
227 在BSD4.*,libc4和libc5中都是`int'.
244 .B byeyear <love_my_love@263.net >
247 .SH "《中国linux论坛man手册页翻译计划》:"
248 .BI http://cmpp.linuxforum.net