Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Perl / General Perl Topics / September 2003



Tip: Looking for answers? Try searching our database.

Bind to specific IP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Busby - 30 Sep 2003 23:09 GMT
List,
   How can I make LWP::UserAgent bind to a specific IP address?  I cannot
find in archives or with google.

David Busby
Systems Engineer
busby@pnts.com
Andy Lester - 30 Sep 2003 23:24 GMT
>List,
>     How can I make LWP::UserAgent bind to a specific IP address?  I cannot
>find in archives or with google.

What exactly do you mean "bind to a specific IP address"?

xoa
Signature

Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance

David Busby - 30 Sep 2003 23:21 GMT
My computer has multiple IP addresses.  I would like the local socket
connection (outbound) that LWP::UserAgent will use to be 66.236.xx.yy, not
the default of 66.236.aa.bb.  So if I have like 4 IP's on a machine
LWP::UserAgent will pick the default, but I want a specific one.  Like
calling:

socket();
bind();
connect();

Now my client will come from a specific IP, port I don't care.

/B

----- Original Message -----
From: "Andy Lester" <andy@petdance.com>
To: "David Busby" <busby@pnts.com>
Cc: <libwww@perl.org>
Sent: Tuesday, September 30, 2003 15:24
Subject: Re: Bind to specific IP

> >List,
> >     How can I make LWP::UserAgent bind to a specific IP address?  I cannot
[quoted text clipped - 3 lines]
>
> xoa
David Busby - 30 Sep 2003 23:29 GMT
List,
   Ok I got this in:

@LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => "66.236.xx.yy");
my $ua = LWP::UserAgent->new( \
 agent=>'Mozilla/4.0', \
 timeout=>10) or die($!);

But I get this:
Name "LWP::Protocol::http::EXTRA_SOCK_OPTS" used only once: possible typo at
./thing.pl line 28.

Google says this is cause I only write the option, never read in my script.
This is caused by #!/usr/bin/perl -w

That seems odd, shouldn't the read in LWP somewhere fix it?

/B

----- Original Message -----
From: "David Busby" <busby@pnts.com>
To: "Andy Lester" <andy@petdance.com>
Cc: <libwww@perl.org>
Sent: Tuesday, September 30, 2003 15:21
Subject: Re: Bind to specific IP

> My computer has multiple IP addresses.  I would like the local socket
> connection (outbound) that LWP::UserAgent will use to be 66.236.xx.yy, not
[quoted text clipped - 25 lines]
> >
> > xoa
David Busby - 30 Sep 2003 23:32 GMT
Please disregard me on this thread...I got it working...thanks for the help.

/B

----- Original Message -----
From: "David Busby" <busby@pnts.com>
To: <libwww@perl.org>
Sent: Tuesday, September 30, 2003 15:29
Subject: Re: Bind to specific IP

> List,
>     Ok I got this in:
[quoted text clipped - 51 lines]
> > >
> > > xoa
David - 30 Sep 2003 23:26 GMT
There's a variable

@LWP::Protocol::http::EXTRA_SOCK_OPTS

that gets passed to IO::Socket::INET::new

In theory, setting it to (LocalAddr => "myipaddress")
should do the trick.

I haven't tried it though.

-----Original Message-----
From: David Busby [mailto:busby@pnts.com]
Sent: Tuesday, September 30, 2003 6:10 PM
To: libwww@perl.org
Subject: Bind to specific IP

List,
   How can I make LWP::UserAgent bind to a specific IP address?  I cannot
find in archives or with google.

David Busby
Systems Engineer
busby@pnts.com
David - 30 Sep 2003 23:40 GMT
That has to do with the order in which the compiler sees the variables.

It's used deep in the heart of LWP, which isn't loaded until it's needed,
so the Perl compiler doesn't know about it yet.

Does it work, though?

-----Original Message-----
From: David Busby [mailto:busby@pnts.com]
Sent: Tuesday, September 30, 2003 6:29 PM
To: libwww@perl.org
Subject: Re: Bind to specific IP

List,
   Ok I got this in:

@LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => "66.236.xx.yy");
my $ua = LWP::UserAgent->new( \
 agent=>'Mozilla/4.0', \
 timeout=>10) or die($!);

But I get this:
Name "LWP::Protocol::http::EXTRA_SOCK_OPTS" used only once: possible typo
at
.../thing.pl line 28.

Google says this is cause I only write the option, never read in my script.
This is caused by #!/usr/bin/perl -w

That seems odd, shouldn't the read in LWP somewhere fix it?

/B

----- Original Message -----
From: "David Busby" <busby@pnts.com>
To: "Andy Lester" <andy@petdance.com>
Cc: <libwww@perl.org>
Sent: Tuesday, September 30, 2003 15:21
Subject: Re: Bind to specific IP

> My computer has multiple IP addresses.  I would like the local socket
> connection (outbound) that LWP::UserAgent will use to be 66.236.xx.yy,
not
> the default of 66.236.aa.bb.  So if I have like 4 IP's on a machine
> LWP::UserAgent will pick the default, but I want a specific one.  Like
[quoted text clipped - 24 lines]
> >
> > xoa
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2012 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.