The sockets.ping (undocumented) function is not working
for very fast connections (response time <1ms) because
it then returns 0 which is the ping-no-answer value.
I suggest that in that case ping() should return a 1
instead.
Hi,
I noticed the repository add where ping was changed
according to Tom's suggestion. I wonder if this was
nescessary (as I already showed (*) how in Dialect any
ambiguity between false and 0 could be avoided).
If the retturn value of ping should be changed I would like to
suggest to return a negative value where now false is
returned. This would avoid having a function that can return
different data types - which should be avoided IMHO - and
still leave the possibility to detect very fast connections.
An emulation of how this could work:
import "sockets"
myping = func( s )
import "sockets"
local r = sockets.ping( s )
if r isa boolean and not r then
return -1
else
return r
endif
endfunc
for i = 1 to 8
retval = myping( "128.0.0.1")
if retval < 0 then
print "Ping Timeout...", cr
else
print "Ping time: ", retval, " ms", cr
endif
endfor
Andr
# (* ) # how to detect false differs from 0
import "sockets"
for i = 1 to 1024
retval = sockets.ping( "128.0.0.1" ) # My
fastest connection :)
if retval isa boolean and not retval then
print "Ping Timeout..."
elif retval = 0 then
print "Ping time: < 1 ms!", cr
else
print "Ping time: ", retval, " ms", cr
endif
endfor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=462273
I sent a fix to Guilect for verification.
(Does not solve the WinCE ping problem!)
Tom
Logged In: YES
user_id=423153
Hi,
I noticed the repository add where ping was changed
according to Tom's suggestion. I wonder if this was
nescessary (as I already showed (*) how in Dialect any
ambiguity between false and 0 could be avoided).
If the retturn value of ping should be changed I would like to
suggest to return a negative value where now false is
returned. This would avoid having a function that can return
different data types - which should be avoided IMHO - and
still leave the possibility to detect very fast connections.
An emulation of how this could work:
import "sockets"
myping = func( s )
import "sockets"
local r = sockets.ping( s )
if r isa boolean and not r then
return -1
else
return r
endif
endfunc
for i = 1 to 8
retval = myping( "128.0.0.1")
if retval < 0 then
print "Ping Timeout...", cr
else
print "Ping time: ", retval, " ms", cr
endif
endfor
Andr
# (* ) # how to detect false differs from 0
import "sockets"
for i = 1 to 1024
retval = sockets.ping( "128.0.0.1" ) # My
fastest connection :)
if retval isa boolean and not retval then
print "Ping Timeout..."
elif retval = 0 then
print "Ping time: < 1 ms!", cr
else
print "Ping time: ", retval, " ms", cr
endif
endfor