Ping

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Ping

Bernat Romagosa
Hi list,

How does one ping a host from Pharo? I see there is a #ping: method at Socket class, but it's painfully slow... I've tried to use ZnClient as follows:

isUp := [ (ZnClient new head: aUrl) isNil ]
on: Error
do: [ false ].

But it's still way too slow... I don't want to perform a full GET request, just an ICMP one.

Thanks!

Bernat.

--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: Ping

Sven Van Caekenberghe-2
Socket class>>#ping does not do an ICMP ping at all, I doubt there is even a primitive to do that.
Socket does do only UDP/TCP sockets. I always thought that ICMP pings are not 'normal' UDP packets, but I could be wrong.

If you know that the other end is an HTTP server, a HEAD request could be useful.

I guess that what you mean by slow is that the timeouts are too high for a quick negative answer.

There is ZnClinetTests>>#testIfFailNonExistingHost that fails pretty quickly, but that is for a non-existing DNS lookup.
An actual connect does currently not honor the ZnClient>>#timeout: setting, that should be fixed, then you should be able to do

ZnClient new
        beOneShot;
        timeout: 0;
        head: 'http://zn.stfx.eu'.

I'll put it on my list.

On 17 Sep 2012, at 17:44, Bernat Romagosa <[hidden email]> wrote:

> Hi list,
>
> How does one ping a host from Pharo? I see there is a #ping: method at Socket class, but it's painfully slow... I've tried to use ZnClient as follows:
>
> isUp := [ (ZnClient new head: aUrl) isNil ]
> on: Error
> do: [ false ].
>
> But it's still way too slow... I don't want to perform a full GET request, just an ICMP one.
>
> Thanks!
>
> Bernat.
>
> --
> Bernat Romagosa.

--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill




Reply | Threaded
Open this post in threaded view
|

Re: Ping

hernanmd
In reply to this post by Bernat Romagosa
Search for the #ping: in ICMPSocket class, IIRC it is included in OpenQwaq.

Hernán

On 17/09/2012 12:44, Bernat Romagosa wrote:

> Hi list,
>
> How does one ping a host from Pharo? I see there is a #ping: method at
> Socket class, but it's painfully slow... I've tried to use ZnClient as
> follows:
>
>     isUp := [ (ZnClient new head: aUrl) isNil ]
>     on: Error
>     do: [ false ].
>
>
> But it's still way too slow... I don't want to perform a full GET
> request, just an ICMP one.
>
> Thanks!
>
> Bernat.
>
> --
> Bernat Romagosa.


Reply | Threaded
Open this post in threaded view
|

Re: Ping

Stéphane Ducasse

On Sep 17, 2012, at 9:23 PM, Hernán Morales Durand wrote:

> Search for the #ping: in ICMPSocket class, IIRC it is included in OpenQwaq.

which is GPL so watch out… it is a plague and contagious.


>
> Hernán
>
> On 17/09/2012 12:44, Bernat Romagosa wrote:
>> Hi list,
>>
>> How does one ping a host from Pharo? I see there is a #ping: method at
>> Socket class, but it's painfully slow... I've tried to use ZnClient as
>> follows:
>>
>>    isUp := [ (ZnClient new head: aUrl) isNil ]
>>    on: Error
>>    do: [ false ].
>>
>>
>> But it's still way too slow... I don't want to perform a full GET
>> request, just an ICMP one.
>>
>> Thanks!
>>
>> Bernat.
>>
>> --
>> Bernat Romagosa.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Ping

Bernat Romagosa
Thanks all!

I got ICMPSocket from the OpenQwaq repo, but it doesn't seem to work very well...

ICMPSocket ping: 'www.google.com'

This runs for a while and then a confirmation window pops up asking whether I'd like to keep waiting for the server.

For now I'll go with my implementation and wait for Sven's fix.

Cheers!

2012/9/17 Stéphane Ducasse <[hidden email]>

On Sep 17, 2012, at 9:23 PM, Hernán Morales Durand wrote:

> Search for the #ping: in ICMPSocket class, IIRC it is included in OpenQwaq.

which is GPL so watch out… it is a plague and contagious.


>
> Hernán
>
> On 17/09/2012 12:44, Bernat Romagosa wrote:
>> Hi list,
>>
>> How does one ping a host from Pharo? I see there is a #ping: method at
>> Socket class, but it's painfully slow... I've tried to use ZnClient as
>> follows:
>>
>>    isUp := [ (ZnClient new head: aUrl) isNil ]
>>    on: Error
>>    do: [ false ].
>>
>>
>> But it's still way too slow... I don't want to perform a full GET
>> request, just an ICMP one.
>>
>> Thanks!
>>
>> Bernat.
>>
>> --
>> Bernat Romagosa.
>
>





--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: Ping

Sven Van Caekenberghe-2
Hi Bernat,

On 18 Sep 2012, at 11:42, Bernat Romagosa <[hidden email]> wrote:

> For now I'll go with my implementation and wait for Sven's fix.

I fixed that this morning with the following commit:

===
Name: Zinc-HTTP-SvenVanCaekenberghe.303
Author: SvenVanCaekenberghe
Time: 18 September 2012, 10:03:40 am
UUID: 9f5a3863-fc08-470d-b8a1-d44169952a66
Ancestors: Zinc-HTTP-SvenVanCaekenberghe.302

Refactored ZnNetworkingUtils>>#socketStreamToUrlDirectly: to honor/use the correct timeout both when doing a DNS lookup as well as during connect by using NetNameResolver directly as well as using #openConnectionToHost:port:timeout:
===

Something like this should work:

[ [ (ZnClient new
        beOneShot;
        enforceHttpSuccess: true;
        timeout: 1/10;
        head: 'http://www.google.com') isNil ] on: Error do: [ false ] ] timeToRun.

But be careful, you are testing many things here:

- that you have network access
- that the hostname resolves (you can also specify an IP address to skp this)
- that the host is reachable (that you can connect to it)
- that it allows an HTTP connection
- that it aswers to HEAD /

HTH,

Sven


--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill




Reply | Threaded
Open this post in threaded view
|

Re: Ping

Bernat Romagosa
Hi Sven,

so cool! Most of these things are actually the ones I need to test, so everything should be okay :)

Thanks a lot!

Bernat.

2012/9/18 Sven Van Caekenberghe <[hidden email]>
Hi Bernat,

On 18 Sep 2012, at 11:42, Bernat Romagosa <[hidden email]> wrote:

> For now I'll go with my implementation and wait for Sven's fix.

I fixed that this morning with the following commit:

===
Name: Zinc-HTTP-SvenVanCaekenberghe.303
Author: SvenVanCaekenberghe
Time: 18 September 2012, 10:03:40 am
UUID: 9f5a3863-fc08-470d-b8a1-d44169952a66
Ancestors: Zinc-HTTP-SvenVanCaekenberghe.302

Refactored ZnNetworkingUtils>>#socketStreamToUrlDirectly: to honor/use the correct timeout both when doing a DNS lookup as well as during connect by using NetNameResolver directly as well as using #openConnectionToHost:port:timeout:
===

Something like this should work:

[ [ (ZnClient new
        beOneShot;
        enforceHttpSuccess: true;
        timeout: 1/10;
        head: 'http://www.google.com') isNil ] on: Error do: [ false ] ] timeToRun.

But be careful, you are testing many things here:

- that you have network access
- that the hostname resolves (you can also specify an IP address to skp this)
- that the host is reachable (that you can connect to it)
- that it allows an HTTP connection
- that it aswers to HEAD /

HTH,

Sven


--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill







--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: Ping

LogiqueWerks
www.yahoo.com also accepts pings

On 18 September 2012 06:58, Bernat Romagosa
<[hidden email]> wrote:

> Hi Sven,
>
> so cool! Most of these things are actually the ones I need to test, so
> everything should be okay :)
>
> Thanks a lot!
>
> Bernat.
>
> 2012/9/18 Sven Van Caekenberghe <[hidden email]>
>>
>> Hi Bernat,
>>
>> On 18 Sep 2012, at 11:42, Bernat Romagosa <[hidden email]>
>> wrote:
>>
>> > For now I'll go with my implementation and wait for Sven's fix.
>>
>> I fixed that this morning with the following commit:
>>
>> ===
>> Name: Zinc-HTTP-SvenVanCaekenberghe.303
>> Author: SvenVanCaekenberghe
>> Time: 18 September 2012, 10:03:40 am
>> UUID: 9f5a3863-fc08-470d-b8a1-d44169952a66
>> Ancestors: Zinc-HTTP-SvenVanCaekenberghe.302
>>
>> Refactored ZnNetworkingUtils>>#socketStreamToUrlDirectly: to honor/use the
>> correct timeout both when doing a DNS lookup as well as during connect by
>> using NetNameResolver directly as well as using
>> #openConnectionToHost:port:timeout:
>> ===
>>
>> Something like this should work:
>>
>> [ [ (ZnClient new
>>         beOneShot;
>>         enforceHttpSuccess: true;
>>         timeout: 1/10;
>>         head: 'http://www.google.com') isNil ] on: Error do: [ false ] ]
>> timeToRun.
>>
>> But be careful, you are testing many things here:
>>
>> - that you have network access
>> - that the hostname resolves (you can also specify an IP address to skp
>> this)
>> - that the host is reachable (that you can connect to it)
>> - that it allows an HTTP connection
>> - that it aswers to HEAD /
>>
>> HTH,
>>
>> Sven
>>
>>
>> --
>> Sven Van Caekenberghe
>> http://stfx.eu
>> Smalltalk is the Red Pill
>>
>>
>>
>>
>
>
>
> --
> Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re: Ping

Bernat Romagosa
Thanks for the info, I wasn't aware of that.

2012/9/18 Robert Shiplett <[hidden email]>
www.yahoo.com also accepts pings

On 18 September 2012 06:58, Bernat Romagosa
<[hidden email]> wrote:
> Hi Sven,
>
> so cool! Most of these things are actually the ones I need to test, so
> everything should be okay :)
>
> Thanks a lot!
>
> Bernat.
>
> 2012/9/18 Sven Van Caekenberghe <[hidden email]>
>>
>> Hi Bernat,
>>
>> On 18 Sep 2012, at 11:42, Bernat Romagosa <[hidden email]>
>> wrote:
>>
>> > For now I'll go with my implementation and wait for Sven's fix.
>>
>> I fixed that this morning with the following commit:
>>
>> ===
>> Name: Zinc-HTTP-SvenVanCaekenberghe.303
>> Author: SvenVanCaekenberghe
>> Time: 18 September 2012, 10:03:40 am
>> UUID: 9f5a3863-fc08-470d-b8a1-d44169952a66
>> Ancestors: Zinc-HTTP-SvenVanCaekenberghe.302
>>
>> Refactored ZnNetworkingUtils>>#socketStreamToUrlDirectly: to honor/use the
>> correct timeout both when doing a DNS lookup as well as during connect by
>> using NetNameResolver directly as well as using
>> #openConnectionToHost:port:timeout:
>> ===
>>
>> Something like this should work:
>>
>> [ [ (ZnClient new
>>         beOneShot;
>>         enforceHttpSuccess: true;
>>         timeout: 1/10;
>>         head: 'http://www.google.com') isNil ] on: Error do: [ false ] ]
>> timeToRun.
>>
>> But be careful, you are testing many things here:
>>
>> - that you have network access
>> - that the hostname resolves (you can also specify an IP address to skp
>> this)
>> - that the host is reachable (that you can connect to it)
>> - that it allows an HTTP connection
>> - that it aswers to HEAD /
>>
>> HTH,
>>
>> Sven
>>
>>
>> --
>> Sven Van Caekenberghe
>> http://stfx.eu
>> Smalltalk is the Red Pill
>>
>>
>>
>>
>
>
>
> --
> Bernat Romagosa.




--
Bernat Romagosa.