Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

How do I bind to a particular Interface ?

by niley (Initiate)
on Aug 08, 2002 at 20:42 UTC ( #188734=perlquestion: print w/replies, xml ) Need Help??

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....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://188734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2022-05-29 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?