.\" Copyright (c) 1983, 1991, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     From: @(#)send.2	8.2 (Berkeley) 2/21/94
.\" %FreeBSD: src/lib/libc/sys/send.2,v 1.27.2.1 2005/01/31 00:27:01 keramida Exp %
.\"
.\" $FreeBSD$
.Dd February 15, 1995
.Dt SEND 2
.Os
.Sh ̾��
.Nm send ,
.Nm sendto ,
.Nm sendmsg
.Nd �����åȤ����å���������������
.Sh �饤�֥��
.Lb libc
.Sh ��
.In sys/types.h
.In sys/socket.h
.Ft ssize_t
.Fn send "int s" "const void *msg" "size_t len" "int flags"
.Ft ssize_t
.Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
.Ft ssize_t
.Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
.Sh ����
.Fn send
�ؿ������
.Fn sendto
�����ƥॳ���뤪���
.Fn sendmsg
�����ƥॳ����ϡ���å��������̤Υ����åȤ���������Τ˻��Ѥ���ޤ���
.Fn send
�ؿ��ϡ������åȤ�
.Em ��³���줿
���֤ˤ���Ȥ��ˤ������ѤǤ���Τ��Ф���
.Fn sendto
��
.Fn sendmsg
�Ϥ��ĤǤ���ѤǤ��ޤ���
.Pp
�������åȤΥ��ɥ쥹��
.Fa to
��Ϳ����
.Fa tolen
�Ǥ��Υ���������ꤷ�ޤ���
��å�������Ĺ����
.Fa len
�ǻ��ꤷ�ޤ���
��å�������Ĺ�����ƴ��ؤȤʤ�ץ��ȥ�����Բ�ʬ���̲�Ǥ��ʤ���硢
���顼
.Er EMSGSIZE
���֤�����å��������������ޤ���
.Pp
.Fn send
�Ǥϡ������Ǥ��ʤ����ȤϤޤä���������ޤ���
����� -1 �ϥ�������Ǹ��Ф��줿���顼�򼨤��ޤ���
.Pp
���������å��������ݻ����륹�ڡ����������åȤ�̵�����
.Fn send
���̾�֥��å����ޤ���
�������������åȤ���֥��å��������ϥ⡼�ɤ����ꤵ��Ƥ�������̤Ǥ���
.Xr select 2
�����ƥॳ�������Ѥ��ơ������¿���Υǡ����򤤤������Ǥ��뤫Ƚ��Ǥ��ޤ���
.Pp
.Fa flags
�����ˤϼ��˼�������ΤΤ���
1 �Ĥޤ���ʣ����ޤ�뤳�Ȥ���ǽ�Ǥ�:
.Bd -literal
#define	MSG_OOB		0x1   /* �Ӱ賰�ǡ������������ */
#define	MSG_PEEK	0x2   /* �忮��å����������� */
#define	MSG_DONTROUTE	0x4   /* �롼�ƥ��󥰤�Х��ѥ�����
                                 ���󥿥ե�������ľ�ܻ��Ѥ��� */
#define	MSG_EOR		0x8   /* ���Υǡ����ǥ쥳���ɤ�λ���� */
#define	MSG_EOF		0x100 /* ���Υǡ����ǥȥ�󥶥�������λ���� */
.Ed
.Pp
�ե饰
.Dv MSG_OOB
�ϡ����γ�ǰ�򥵥ݡ��Ȥ��륽���å� (���Ȥ��С�
.Dv SOCK_STREAM )
���
.Dq �Ӱ賰
�ǡ�������������Τ˻��Ѥ���ޤ���
���ؤȤʤäƤ���ץ��ȥ����
.Dq �Ӱ賰
�ǡ����򥵥ݡ��Ȥ���ɬ�פ�����ޤ���
.Dv MSG_EOR
�ϡ����γ�ǰ�򥵥ݡ��Ȥ���ץ��ȥ����ѤΥ쥳���ɥޡ����򼨤��Τ˻��Ѥ���ޤ���
.Dv MSG_EOF
�ϡ������åȤ�����¦�Υ���åȥ�������׵ᤷ��
����ǡ����ν�λ���ˡ�Ŭ�ڤʻؼ����������׵ᤷ�ޤ���
���Υե饰�ϡ�
.Dv PF_INET
�ץ��ȥ���ե��ߥ��
.Dv SOCK_STREAM
�����åȤˤĤ��Ƥ����������졢�ȥ�󥶥������
.Tn TCP
.Xr ( ttcp 4
�򻲾�) ���������Τ˻��Ѥ���ޤ���
.Dv MSG_DONTROUTE
���̾���ǥץ������ޤ��Ϸ�ϩ����ץ������ǻ��Ѥ���ޤ���
.Pp
.Fa msghdr
��¤�Τξܺ٤ˤĤ��Ƥϡ�
.Xr recv 2
�򻲾Ȥ��Ƥ���������
.Sh �����
���θƤӽФ����������줿ʸ�������֤������顼������������ -1 ���֤��ޤ���
.Sh ���顼
.Fn send
�ؿ������
.Fn sendto
�����ƥॳ���뤪���
.Fn sendmsg
�����ƥॳ����ϼ��ξ��˼¹Ԥ˼��Ԥ��ޤ�:
.Bl -tag -width Er
.It Bq Er EBADF
̵���ʵ��һҤ����ꤵ��ޤ�����
.It Bq Er EACCES
���襢�ɥ쥹�ϥ֥����ɥ��㥹�ȥ��ɥ쥹�Ǥ��ꡢ
.Dv SO_BROADCAST
�������åȾ�����ꤵ��Ƥ��ޤ���
.It Bq Er ENOTSOCK
����
.Fa s
�������åȤǤϤ���ޤ���
.It Bq Er EFAULT
�����ˤĤ���̵���ʥ桼�����֥��ɥ쥹�����ꤵ��ޤ�����
.It Bq Er EMSGSIZE
�����åȤϥ�å��������Բ�ʬ����������뤳�Ȥ��׵ᤷ�Ƥ��ޤ�����
����������å������Υ������Ǥ��Բ�ǽ�Ǥ���
.It Bq Er EAGAIN
�����åȤ���֥��å��󥰤ȥޡ�������Ƥ��ꡢ
�׵ᤵ�줿���ϥ֥��å������Ǥ��礦��
.It Bq Er ENOBUFS
�����ƥ�������Хåե��������Ƥ뤳�Ȥ��Ǥ��ޤ���Ǥ�����
�Хåե������Ѳ�ǽ�ˤʤä��Ȥ��������������ǽ��������ޤ���
.It Bq Er ENOBUFS
�ͥåȥ�����󥿥ե������Ѥν��ϥ��塼�����դǤ�����
����ϰ��̤ˡ����󥿥ե���������������ߤ�����ΤΡ�
���줬���Ū�����Ԥˤ�äƵ����ä����Ȥ򼨤��ޤ���
.It Bq Er EHOSTUNREACH
��⡼�ȥۥ��Ȥ���ã�Ǥ��ޤ���Ǥ�����
.It Bq Er EISCONN
���襢�ɥ쥹�����ꤵ�졢�����ƥ����åȤϴ�����³����Ƥ��ޤ���
.It Bq Er ECONNREFUSED
�����åȤ���ICMP ��������ã��å�������
�Ǹ������������å���������������ޤ�����
ŵ��Ū�ˤϡ������Ԥ���⡼�ȥݡ��Ȥ��Ե����Ƥ��ʤ����Ȥ��̣���ޤ���
.It Bq Er EHOSTDOWN
��⡼�ȥۥ��Ȥ������󤷤Ƥ��ޤ�����
.It Bq Er ENETDOWN
��⡼�ȥͥåȥ���������󤷤Ƥ��ޤ�����
.It Bq Er EPERM
.Dv SOCK_RAW
�����åȤ���Ѥ��Ƥ���ץ������� jail ����ˤ��ꡢIP �إå���
��ǻ��ꤵ��Ƥ����������Υ��ɥ쥹����������κ�ץ�������
����դ����Ƥ��� IP ���ɥ쥹�Ȱ��פ��ޤ���Ǥ�����
.It Bq Er EPIPE
�����åȤ�����ʾ�ǡ����������Ǥ��ޤ���
.Dv ( SBS_CANTSENDMORE
�����Υ����åȤ����ꤵ��Ƥ��ޤ�)��
������̾���Υ����åȤ���³����Ƥ��ʤ����Ȥ��̣���ޤ���
.El
.Sh �Х�
.Fn sendmsg
�ϥǡ�����ž������Ƥ��ޤ��ޤ�ɬ������֥��å����ʤ��Τǡ�
�����ץ󤵤�Ƥ���ե����뵭�һҤ�
.Dv AF_UNIX
�ɥᥤ�󥽥��å�
.Xr ( recv 2
�򻲾�) ��ͳ�������������줫��ºݤ��������������
.Fn close
�����ǽ��������ޤ���
���η�̡�����¦���Ĥ����ե����뵭�һҤ����뤳�Ȥˤʤ�ޤ���
������ɻߤ����ǧ�ᥫ�˥���μ����ϡ�
���ץꥱ�������ǹԤ�ɬ�פ�����ޤ���
.Sh ��Ϣ����
.Xr fcntl 2 ,
.Xr getsockopt 2 ,
.Xr recv 2 ,
.Xr select 2 ,
.Xr socket 2 ,
.Xr write 2
.Sh ���
.Fn send
�ؿ���
.Bx 4.2
���о줷�ޤ�����