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 .\" @(#)socketpair.2 6.4 (Berkeley) 3/10/91
34 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
35 .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
36 .\" Modified 2002-07-22 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
38 .\" 2008-10-11, mtk: Add description of SOCK_NONBLOCK and SOCK_CLOEXEC
40 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
41 .\" all rights reserved.
42 .\" Translated 1997-03-03, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
43 .\" Updated 2002-09-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2008-11-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
47 .\"WORD: socket ¥½¥±¥Ã¥È
49 .\"WORD: domain ¥É¥á¥¤¥ó
50 .\"WORD: descriptor ¥Ç¥£¥¹¥¯¥ê¥×¥¿
51 .\"WORD: family ¥Õ¥¡¥ß¥ê
52 .\"WORD: implement ¼ÂÁõ
54 .TH SOCKETPAIR 2 2008-10-11 "Linux" "Linux Programmer's Manual"
56 .\"O socketpair \- create a pair of connected sockets
58 socketpair \- Àܳ¤µ¤ì¤¿¥½¥±¥Ã¥È¤Î¥Ú¥¢¤òºîÀ®¤¹¤ë
61 .\"O .BR "#include <sys/types.h>" " /* See NOTES */"
62 .BR "#include <sys/types.h>" " /* ¡ÖÃí°Õ¡×»²¾È */"
64 .B #include <sys/socket.h>
66 .BI "int socketpair(int " domain ", int " type ", int " protocol \
71 .\"O .BR socketpair ()
72 .\"O call creates an unnamed pair of connected sockets in the specified
76 .\"O and using the optionally specified
79 ¤Ï¡¢»ØÄꤵ¤ì¤¿¥É¥á¥¤¥ó
83 ¤Ç̾Á°¤Î¤Ê¤¤¥½¥±¥Ã¥È¤ÎÀܳ¤µ¤ì¤¿¥Ú¥¢¤òºîÀ®¤¹¤ë¡£
85 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢¤³¤Î¥×¥í¥È¥³¥ë¤òÍѤ¤¤ë¡£
86 .\"O For further details of these arguments, see
88 ¤³¤ì¤é¤Î°ú¤¿ô¤Î¾ÜºÙ¤Ï
92 .\"O The descriptors used in referencing the new sockets are returned in
96 ¿·¤·¤¤¥½¥±¥Ã¥È¤Î»²¾È¤Ë»ÈÍѤ¹¤ë¥Ç¥£¥¹¥¯¥ê¥×¥¿ (descriptor) ¤¬
101 .\"O The two sockets are indistinguishable.
102 Æó¤Ä¤Î¥½¥±¥Ã¥È¤ÏÁ´¤¯Æ±¤¸¤Ç¤¢¤ë¡£
103 .\"O .SH "RETURN VALUE"
105 .\"O On success, zero is returned.
106 .\"O On error, \-1 is returned, and
108 .\"O is set appropriately.
109 À®¸ù¤·¤¿¾ì¹ç¤Ï¥¼¥í¤òÊÖ¤¹¡¢¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
116 .\"O The specified address family is not supported on this machine.
117 ¤³¤Î¥Þ¥·¥ó¤Ç¤Ï»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹¡¦¥Õ¥¡¥ß¥ê¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
122 .\"O does not specify a valid part of the process address space.
125 ¤¬¤³¤Î¥×¥í¥»¥¹¤Ç»È¤¨¤ë¥¢¥É¥ì¥¹¶õ´Ö¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¡£
128 .\"O Too many descriptors are in use by this process.
129 ¤³¤Î¥×¥í¥»¥¹¤¬»ÈÍѤ·¤Æ¤¤¤ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¿ô¤¬Â¿¤¹¤®¤ë¡£
132 .\"O The system limit on the total number of open files has been reached.
133 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ÎÁí¿ô¤¬¥·¥¹¥Æ¥àÁ´ÂΤξå¸Â¤Ë㤷¤¿¡£
136 .\"O The specified protocol does not support creation of socket pairs.
137 »ØÄꤵ¤ì¤¿¥×¥í¥È¥³¥ë¤Ç¤Ï¥½¥±¥Ã¥È¤Î¥Ú¥¢¤ÎºîÀ®¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
140 .\"O The specified protocol is not supported on this machine.
141 ¤³¤Î¥Þ¥·¥ó¤Ç¤Ï»ØÄꤵ¤ì¤¿¥×¥í¥È¥³¥ë¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
142 .\"O .SH "CONFORMING TO"
144 .\"O 4.4BSD, POSIX.1-2001.
146 .\"O .BR socketpair ()
147 .\"O function call appeared in 4.2BSD.
148 .\"O It is generally portable to/from
149 .\"O non-BSD systems supporting clones of the BSD socket layer (including
150 .\"O System V variants).
151 4.4BSD, POSIX.1-2001.
153 ´Ø¿ô¥³¡¼¥ë¤Ï 4.2BSD ¤Ç¸½¤ï¤ì¤¿¡£°ìÈÌ¤Ë (System V ¤ÎÊѼï¤ò´Þ¤á¤Æ)
154 BSD ¤Î¥½¥±¥Ã¥ÈÁؤΥ¯¥í¡¼¥ó¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡¢BSD °Ê³°¤Î¥·¥¹¥Æ¥à¤È¡¢
158 .\"O On Linux, the only supported domain for this call is
160 .\"O (or synonymously,
162 .\"O (Most implementations have the same restriction.)
163 Linux ¤Ç¤Ï¡¢¤³¤Î´Ø¿ô¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥É¥á¥¤¥ó¤Ï
168 (¤Û¤È¤ó¤É¤Î¼ÂÁõ¤ÇƱ¤¸À©¸Â¤¬¤¢¤ë)
170 .\"O Since Linux 2.6.27,
171 .\"O .BR socketpair ()
173 .\"O .BR SOCK_NONBLOCK
175 .\"O .BR SOCK_CLOEXEC
176 .\"O flags described in
178 Linux 2.6.27 °Ê¹ß¤Ç¤Ï¡¢
184 ¤ËÂбþ¤·¤Æ¤¤¤ë¡£¥Õ¥é¥°¤ÎÀâÌÀ¤Ï
188 .\"O POSIX.1-2001 does not require the inclusion of
189 .\"O .IR <sys/types.h> ,
190 .\"O and this header file is not required on Linux.
191 .\"O However, some historical (BSD) implementations required this header
192 .\"O file, and portable applications are probably wise to include it.
195 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ïɬ¿Ü¤È¤µ¤ì¤Æ¤ª¤é¤º¡¢
196 Linux ¤Ç¤Ï¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ÏɬÍפǤϤʤ¤¡£
197 ¤·¤«¤·¡¢Îò»ËŪ¤Ë¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¼ÂÁõ (BSD ·Ï) ¤Ç¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬
198 ɬÍפǤ¢¤ê¡¢°Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤³¤Î¥Õ¥¡¥¤¥ë¤ò
199 ¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤Î¤¬¸ÌÀ¤Ç¤¢¤í¤¦¡£