-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperlfun_socketpair.txt
24 lines (18 loc) · 1.19 KB
/
perlfun_socketpair.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL
Creates an unnamed pair of sockets in the specified domain, of
the specified type. DOMAIN, TYPE, and PROTOCOL are specified the
same as for the syscall of the same name. If unimplemented,
raises an exception. Returns true if successful.
On systems that support a close-on-exec flag on files, the flag
will be set for the newly opened file descriptors, as determined
by the value of $^F. See "$^F" in perlvar.
Some systems define "pipe" in terms of "socketpair", in which a
call to "pipe($rdr, $wtr)" is essentially:
use Socket;
socketpair(my $rdr, my $wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
shutdown($rdr, 1); # no more writing for reader
shutdown($wtr, 0); # no more reading for writer
See perlipc for an example of socketpair use. Perl 5.8 and later
will emulate socketpair using IP sockets to localhost if your
system implements sockets but not socketpair.
Portability issues: "socketpair" in perlport.