libapa...ockAddr(3pm)
β¨ NAME β¨
APR::SockAddr β the Perl API for the APR socket address structure π
like, it's the lil' object that knows who's on the other end of your socket, bestie
π¦ Synopsis π¦
use APR::SockAddr ();
my $ip = $sock_addr->ip_get;
my $port = $sock_addr->port;
πΈ Description πΈ
APR::SockAddr gives you access to the fields of a socket address structure. no cap, that's the whole job. π
So like, normally you don't build one of these yourself β you get a socket address object by calling one of these icons:
use Apache2::Connection ();
my $remote_sock_addr = $c->remote_addr;
my $local_sock_addr = $c->remote_local;
π API π
APR::SockAddr serves up the following functions and/or methods, and honestly? slay:
β ip_get
Get the IP address of the socket π«Ά
$ip = $sock_addr->ip_get();
- obj:
$sock_addr(APR::SockAddr object) - ret:
$ip( string ) - since: 2.0.00
Okay so if you already know how perl's Socket does it:
use Socket 'sockaddr_in';
my ($serverport, $serverip) = sockaddr_in(getpeername($local_sock));
my ($remoteport, $remoteip) = sockaddr_in(getpeername($remote_sock));
then in apr-speak that exact same vibe would be written like:
use APR::SockAddr ();
use Apache2::Connection ();
my $serverport = $c->local_addr->port;
my $serverip = $c->local_addr->ip_get;
my $remoteport = $c->remote_addr->port;
my $remoteip = $c->remote_addr->ip_get;
π port
Get the IP address of the socket
$port = $sock_addr->port();
- obj:
$sock_addr(APR::SockAddr object) - ret:
$port( integer ) - since: 2.0.00
Example: see ip_get()
not me noticing it says "Get the IP address of the socket" up there π that's literally what the page says, i'm just the messenger, the port is a port tho π
π Unsupported API π
APR::SockAddr also hands you an auto-generated Perl interface for a few other methods that aren't tested at the moment, so their API is subject to change. β οΈ These methods will be finalized later, whenever a need arises. So like β if you wanna rely on any of the following methods, pls contact the the mod_perl development mailing list so we can help each other take the steps necessary to shift the method to an officially supported API. teamwork makes the dream work fr fr π«Ά
π§ equal
META: Autogenerated - needs to be reviewed/completed
Check whether the IP addresses in two APR socket addresses are equivalent. There's appropriate logic present for comparing IPv4-mapped IPv6 addresses with IPv4 addresses. π
$ret = $addr1->equal($addr2);
- obj:
$addr1(APR::SockAddr object)- One of the APR socket addresses.
- arg1:
$addr2(APR::SockAddr object)- The other APR socket address.
- ret:
$ret( integer ) - since: subject to change
The return value will be non-zero if the addresses are equivalent. β
π See Also π
mod_perl 2.0 documentation β go read it, iykyk π
π Copyright π
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.
π Authors π
The mod_perl development team and numerous contributors. iconic behavior honestly.
okay that's the whole thing, no notes π
this lil' page is from User Contributed Perl Documentation, generated by perl v5.42.3 on 2026-08-20, and yes it's still filed under that tragically truncated name libapa...ockAddr(3pm). bye bestie, go read your socket addresses πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libapache2-mod-perl2 2.0.13-2build3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms