📄 socket.pm
字号:
=head2 C<send>Write data to the socket $wlen = $sock->send($buf, $opt_len);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to write to=item arg1: C<$buf> ( scalar )The data to send=item opt arg2: C<$opt_len> ( int )There is no need to pass this argument, unless you want to send lessdata than contained in C<$buf>.=item ret: C<$wlen> ( integer )How many bytes were sent=item since: 2.0.00=backFor examples see the C<L<recv|/C_recv_>> item.=head2 C<timeout_get>Get socket timeout settings $usecs = $sock->timeout_get();=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to set up.=item ret: C<$usecs> ( number)Currently set timeout in microseconds (and also the blocking IObehavior). See (C<L<APR::timeout_set|/C__timeout_set_>>) for possiblevalues and their meaning.=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>=item since: 2.0.00=back=head2 C<timeout_set>Setup socket timeout. $sock->timeout_set($usecs);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to set up.=item arg1: C<$usecs> ( number )Value for the timeout in microseconds and also the blocking IObehavior.The possible values are:=over=item t E<gt> 0C<L<send()|/C__send_>> and C<L<recv()|/C__recv_)>> throw(C<L<APR::Const::TIMEUP|docs::2.0::api::APR::Const/C__APR__TIMEUP_>>exception) if specified time elapses with no data sent or received.Notice that the positive value is in micro seconds. So if you want toset the timeout for 5 seconds, the value should be: 5_000_000.This mode sets the socket into a non-blocking IO mode.=item t == 0C<L<send()|/C__send_>> and C<L<recv()|/C__recv_)>> calls never block.=item t E<lt> 0C<L<send()|/C__send_>> and C<L<recv()|/C__recv_)>> calls block.Usually just -1 is used for this case, but any negative value will do.This mode sets the socket into a blocking IO mode.=item ret: no return value=back=item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>=item since: 2.0.00=back=head1 Unsupported APIC<APR::Socket> also provides auto-generated Perl interface for a fewother methods which aren't tested at the moment and therefore theirAPI is a subject to change. These methods will be finalized later as aneed arises. If you want to rely on any of the following methodsplease contact the L<the mod_perl development mailinglist|maillist::dev> so we can help each other take the steps necessaryto shift the method to an officially supported API.=head2 C<bind>META: Autogenerated - needs to be reviewed/completedBind the socket to its associated port $ret = $sock->bind($sa);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to bind=item arg1: C<$sa>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )The socket address to bind to=item ret: C<$ret> ( integer )=item since: subject to change=backThis may be where we will find out if there is any other processusing the selected port.=head2 C<close>META: Autogenerated - needs to be reviewed/completedClose a socket. $ret = $sock->close();=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to close=item ret: C<$ret> ( integer )=item since: subject to change=back=head2 C<connect>META: Autogenerated - needs to be reviewed/completedIssue a connection request to a socket either on the same machineor a different one. $ret = $sock->connect($sa);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket we wish to use for our side of the connection =item arg1: C<$sa>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAdrr>> )The address of the machine we wish to connect to. If NULL,APR assumes that the sockaddr_in in the apr_socket iscompletely filled out.=item ret: C<$ret> ( integer )=item since: subject to change=back=head2 C<listen>META: Autogenerated - needs to be reviewed/completedListen to a bound socket for connections. $ret = $sock->listen($backlog);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to listen on=item arg1: C<$backlog> ( integer )The number of outstanding connections allowed in the socketslisten queue. If this value is less than zero, the listenqueue size is set to zero.=item ret: C<$ret> ( integer )=item since: subject to change=back=head2 C<recvfrom>META: Autogenerated - needs to be reviewed/completed $ret = $from->recvfrom($sock, $flags, $buf, $len);=over 4=item obj: C<$from>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )The apr_sockaddr_t to fill in the recipient info=item arg1: C<$sock>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )The socket to use=item arg2: C<$flags> ( integer )The flags to use=item arg3: C<$buf> ( integer )The buffer to use=item arg4: C<$len> ( string )The length of the available buffer=item ret: C<$ret> ( integer )=item since: subject to change=back=head2 C<sendto>META: Autogenerated - needs to be reviewed/completed $ret = $sock->sendto($where, $flags, $buf, $len);=over 4=item obj: C<$sock>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The socket to send from=item arg1: C<$where>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> )The apr_sockaddr_t describing where to send the data=item arg2: C<$flags> ( integer )The flags to use=item arg3: C<$buf> ( scalar )The data to send=item arg4: C<$len> ( string )The length of the data to send=item ret: C<$ret> ( integer )=item since: subject to change=back=head1 See AlsoL<mod_perl 2.0 documentation|docs::2.0::index>.=head1 Copyrightmod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0.=head1 AuthorsL<The mod_perl development team and numerouscontributors|about::contributors::people>.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -