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 πŸ“š


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