I have had several requests for a way to control the 'LocalAddr' used for connections made by LWP. I think the best way to deal with this is to make is configurable at the IO::Socket::INET level. In this patch I have chosen to make it default from an environment variable. Another approach could be to provide a class method or simply a global variable like $IO::Socket::INET::DEFAULT_LOCAL_ADDR. Any other thoughts or suggestiong for a better environment variable name? This patch is relative to perl5.005_62: --- lib/IO/Socket/INET.pm.62 Tue Oct 26 10:49:28 1999 +++ lib/IO/Socket/INET.pm Tue Oct 26 10:57:51 1999 @@ -14,7 +14,7 @@ use Carp; use Exporter; @ISA = qw(IO::Socket); -$VERSION = "1.24"; +$VERSION = "1.25"; IO::Socket::INET->register_domain( AF_INET ); @@ -93,6 +93,8 @@ sub configure { $arg->{LocalAddr} = $arg->{LocalHost} if exists $arg->{LocalHost} && !exists $arg->{LocalAddr}; + $arg->{LocalAddr} = $ENV{IO_SOCKET_LOCAL_ADDR} + if exists $ENV{IO_SOCKET_LOCAL_ADDR} && !exists $arg->{LocalAddr}; ($laddr,$lport,$proto) = _sock_info($arg->{LocalAddr}, $arg->{LocalPort}, @@ -267,7 +269,7 @@ Creates an C<IO::Socket::INET> object, w newly created symbol (see the C<Symbol> package). C<new> optionally takes arguments, these arguments are in key-value pairs. -In addition to the key-value pairs accepted by L<IO::Socket>, +In addition to the key-value pairs accepted by C<IO::Socket>, C<IO::Socket::INET> provides. @@ -326,7 +328,7 @@ Examples: NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE - + As of VERSION 1.18 all IO::Socket objects have autoflush turned on by default. This was not the case with earlier releases. @@ -364,6 +366,11 @@ Return the address part of the sockaddr peer host in a text form xx.xx.xx.xx =back + +=head1 ENVIRONMENT + +If C<LocalAddr> is not specified it defaults from the environment +variable C<IO_SOCKET_LOCAL_ADDR>. =head1 SEE ALSO Regards, GisleThread Next