curl-and-python

Re: pyCurl : get IP address of the peer socket

From: ferrety ferrety <yferrety_at_gmail.com>
Date: Tue, 9 Sep 2008 16:07:10 +0200

Hi Kjetil, Daniel, Mark

Works like a cham now with pyCurl from CVS.
Thanks for evrything guys ...

cheers
Ferret

On Tue, Sep 9, 2008 at 2:01 PM, Kjetil Jacobsen <kjetilja_at_gmail.com> wrote:
> hi,
>
> my plan is to relelease pycurl 7.19 sometime this week.
>
> regards,
> - kjetil
>
> On Tue, Sep 9, 2008 at 1:31 PM, ferrety ferrety <yferrety_at_gmail.com> wrote:
>> Hi Daniel,
>>
>> Unfortunately, "pycurl" is only compatible with libCurl version 7.18.2
>> (I've checked the source code and there's no reference to
>> "PRIMARY_IP") :
>> http://pycurl.sourceforge.net/
>>
>> So, there no way to use "PRIMARY_IP".
>>
>> While waiting a pyCurl upgrade or another advice, I'm using this litttle hack:
>>
>> import socket
>> from urlparse import urlparse
>>
>> url = 'http://curl.haxx.se/'
>> try:
>> ipadrr = socket.gethostbyname_ex( urlparse( url )[1] )[2][0]
>> except:
>> ipaddr = 'unknown'
>>
>>
>> which works almost all the time.
>>
>> Regards
>> Ferret
>>
>>
>> On Tue, Sep 9, 2008 at 12:48 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>>> On Tue, 9 Sep 2008, ferrety ferrety wrote:
>>>
>>>>> sock = curl.getinfo(pycurl.LASTSOCKET);
>>>
>>>> So, is it the right way to do it?
>>>
>>> No. The Right Way(tm) is to use PRIMARY_IP, but that requires libcurl 7.19.0
>>> and a pycurl updated to support it.
>>>
>>> The LASTSOCKET approach has the fatal flaw that sometimes there's no socket
>>> returned since the connection may have already been closed...
>>>
>>> --
>>>
>>> / daniel.haxx.se
>>> _______________________________________________
>>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>>>
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2008-09-09