On Wed, 10 Dec 2003, Chris Ridd did scribble:
On 10/12/03 7:58 pm, D.Kreft <[EMAIL PROTECTED]> wrote:
On Wed, 10 Dec 2003, Chris Ridd did scribble:
$ldap->socket->peername returns the peer address and port. $ldap->socket's
documented as well ;-)
I just grepped the perldocs for Net::LDAP (v0.2701) and didn't see any
mention of 'peername' or 'socket'. Am I missing something, or has
documentation for this little "trick" been added since 0.2701?
Good point - I'm using 0.30. The socket method existed in 0.2701 (I just
checked), but wasn't documented until more recently (I didn't check when).
It returns an IO::Socket object, which you can call peername on:
my ($port,$iaddr) = sockaddr_in($ldap->socket->peername); my $peerhost = gethostbyaddr($iaddr, AF_INET); my $peerstraddr = inet_ntoa($iaddr);
(Code stolen from 'perldoc -f getpeername')
Oh man, that's ugly.
Sure would be nice to have a *clean* way to get it direct from Net::LDAP
itself (and not from a Socket class). :-)
Yes. There should be a method to get details of the connection. Consider if the connection was done using ldapi, there is no hostname, but there is a path to the unix socket. I guess it might be useful to also get the port number.
How about a method which returns the connect methed 'ldap', 'ldaps' or 'ldapi' followed by relevant details. So ldap and ldaps would be followed by hostname and port, ldapi would be followed by the socket path
Graham.
