1socketpair(3XNET)X/Open Networking Services Library Functionssocketpair(3XNET)
2
3
4
6 socketpair - create a pair of connected sockets
7
9 cc [ flag ... ] file ... -lxnet [ library ... ]
10 #include <sys/socket.h>
11
12 int socketpair(int domain, int type, int protocol, int socket_vector[2]);
13
14
16 The socketpair() function creates an unbound pair of connected sockets
17 in a specified domain, of a specified type, under the protocol option‐
18 ally specified by the protocol argument. The two sockets are identi‐
19 cal. The file descriptors used in referencing the created sockets are
20 returned in socket_vector0 and socket_vector1.
21
22
23 The type argument specifies the socket type, which determines the
24 semantics of communications over the socket. The socket types sup‐
25 ported by the system are implementation-dependent. Possible socket
26 types include:
27
28 SOCK_STREAM Provides sequenced, reliable, bidirectional, connec‐
29 tion-mode byte streams, and may provide a transmis‐
30 sion mechanism for out-of-band data.
31
32
33 SOCK_DGRAM Provides datagrams, which are connectionless-mode,
34 unreliable messages of fixed maximum length.
35
36
37 SOCK_SEQPACKET Provides sequenced, reliable, bidirectional, connec‐
38 tion-mode transmission path for records. A record
39 can be sent using one or more output operations and
40 received using one or more input operations, but a
41 single operation never transfers part of more than
42 one record. Record boundaries are visible to the
43 receiver via the MSG_EOR flag.
44
45
46
47 If the protocol argument is non-zero, it must specify a protocol that
48 is supported by the address family. The protocols supported by the
49 system are implementation-dependent.
50
51
52 The process may need to have appropriate privileges to use the socket‐
53 pair() function or to create some sockets.
54
56 domain Specifies the communications domain in which the sock‐
57 ets are to be created.
58
59
60 type Specifies the type of sockets to be created.
61
62
63 protocol Specifies a particular protocol to be used with the
64 sockets. Specifying a protocol of 0 causes socket‐
65 pair() to use an unspecified default protocol appro‐
66 priate for the requested socket type.
67
68
69 socket_vector Specifies a 2-integer array to hold the file descrip‐
70 tors of the created socket pair.
71
72
74 The documentation for specific address families specifies which proto‐
75 cols each address family supports. The documentation for specific pro‐
76 tocols specifies which socket types each protocol supports.
77
78
79 The socketpair() function is used primarily with UNIX domain sockets
80 and need not be supported for other domains.
81
83 Upon successful completion, this function returns 0. Otherwise, −1 is
84 returned and errno is set to indicate the error.
85
87 The socketpair() function will fail if:
88
89 EAFNOSUPPORT The implementation does not support the specified
90 address family.
91
92
93 EMFILE No more file descriptors are available for this
94 process.
95
96
97 ENFILE No more file descriptors are available for the sys‐
98 tem.
99
100
101 EOPNOTSUPP The specified protocol does not permit creation of
102 socket pairs.
103
104
105 EPROTONOSUPPORT The protocol is not supported by the address family,
106 or the protocol is not supported by the implementa‐
107 tion.
108
109
110 EPROTOTYPE The socket type is not supported by the protocol.
111
112
113
114 The socketpair() function may fail if:
115
116 EACCES The process does not have appropriate privileges.
117
118
119 ENOBUFS Insufficient resources were available in the system to per‐
120 form the operation.
121
122
123 ENOMEM Insufficient memory was available to fulfill the request.
124
125
126 ENOSR There were insufficient STREAMS resources available for the
127 operation to complete.
128
129
131 See attributes(5) for descriptions of the following attributes:
132
133
134
135
136 ┌─────────────────────────────┬─────────────────────────────┐
137 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
138 ├─────────────────────────────┼─────────────────────────────┤
139 │Interface Stability │Standard │
140 ├─────────────────────────────┼─────────────────────────────┤
141 │MT-Level │MT-Safe │
142 └─────────────────────────────┴─────────────────────────────┘
143
145 socket(3XNET), attributes(5), standards(5)
146
147
148
149SunOS 5.11 10 Jun 2002 socketpair(3XNET)