http://www.perlmonks.org?node_id=188734

niley has asked for the wisdom of the Perl Monks concerning the following question: (network programming)

When creating connections to servers, how can I use a particular interface to make the outgoing connection?
I currently create connections with the following code:
IO::Socket::INET->new( PeerAddr => $Remote, PeerPort => $Port, Proto = +> 'tcp' );
All pointers in the right direction appreciated.

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I bind to a particular Interface ?
by sauoq (Abbot) on Aug 09, 2002 at 01:39 UTC
    You can use IO::Socket::INET's LocalAddr property to force the packets out a specific interface.
Re: How do I bind to a particular Interface ?
by hnd (Scribe) on Jun 29, 2009 at 20:54 UTC
    use IO::Scoket; $socket= new IO::Socket( LocalAddr=>$host, LocalPort=>$port, ..... #other arguments ) or die "socket not created\n";
    the $host is the IP of the interface you want and the $port is the port number you want the service to run....