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.
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 <tibabenfortlapalanca@gmail.com> 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
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.
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.
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 <stephane.ducasse@inria.fr>
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.
Hi Bernat, On 18 Sep 2012, at 11:42, Bernat Romagosa <tibabenfortlapalanca@gmail.com> 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
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 <sven@stfx.eu>
Hi Bernat,
On 18 Sep 2012, at 11:42, Bernat Romagosa <tibabenfortlapalanca@gmail.com> 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.
www.yahoo.com also accepts pings On 18 September 2012 06:58, Bernat Romagosa <tibabenfortlapalanca@gmail.com> 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 <sven@stfx.eu>
Hi Bernat,
On 18 Sep 2012, at 11:42, Bernat Romagosa <tibabenfortlapalanca@gmail.com> 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.
Thanks for the info, I wasn't aware of that. 2012/9/18 Robert Shiplett <grshiplett@gmail.com>
www.yahoo.com also accepts pings
On 18 September 2012 06:58, Bernat Romagosa <tibabenfortlapalanca@gmail.com> 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 <sven@stfx.eu>
Hi Bernat,
On 18 Sep 2012, at 11:42, Bernat Romagosa <
tibabenfortlapalanca@gmail.com>
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.
participants (5)
-
Bernat Romagosa -
Hernán Morales Durand -
Robert Shiplett -
Stéphane Ducasse -
Sven Van Caekenberghe