GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
POSIX::Socket(3) User Contributed Perl Documentation POSIX::Socket(3)

POSIX::Socket - Low-level perl interface to POSIX sockets

 use POSIX::Socket
 
 my $rd=_socket(AF_INET, SOCK_DGRAM, 0) or die "socket: $!\n";
 my $wr=_socket(AF_INET, SOCK_DGRAM, 0) or die "socket: $!\n";
 
 my $addr = sockaddr_in(0, inet_aton("127.0.0.1"));
 my $bind_rv=_bind($rd, $addr);
 
 _getsockname($rd, $addr);
 my ($port, $ip) = unpack_sockaddr_in($addr);
 $ip = inet_ntoa($ip);
 die "_getsockname fail!" unless $ip eq "127.0.0.1";
 
 my $ret_val1 = _sendto($wr, $msg, $flags, $addr);
 my $ret_val2 = _recv($rd, $buf, 8192, 0);
 
 _close ($rd);
 _close ($wr);

The primary purpose of this is to use file descriptors instead of file handles for socket operations. File descriptors can be shared between threads and not need dup file handles for each threads.

I hope you enjoyed it.

 $fd = _socket($socket_family, $socket_type, $protocol);
 
 $rv = _close($fd)
 
 $rv = _fcntl($fildes, $cmd, $arg);
 
 $rv = _bind($fd, $addr);
 
 $rv = _connect($fd, $addr);
 
 $n = _recv($fd, $buffer, $len, $flags);
 
 $n = _recvn($fd, $buffer, $len, $flags);
 
 $rv = _getsockname($fd, $addr);
 
 $n = _send($fd, $buffer, $flags);
 
 $n = _sendn($fd, $buffer, $flags);
 
 $n = _sendto($fd, $buf, $flags, $dest_addr);

 $n = _recvfrom($fd, $buf, $len, $flags, $sock_addr);
 
 $new_fd = _accept($fd);
 
 $rv = _listen($fd, $backlog);
 
 $rv = _getsockopt($fd, $level, $optname, $optval, $optlen);
 
 $rv = _setsockopt($fd, $level, $optname, $optval);

Yury Kotlyarov "yura@cpan.org"

POSIX, Socket
2013-07-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.