Menu

#2 Ping not working for fast connections

open
nobody
None
5
2002-09-24
2002-09-24
Tom Arn
No

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.

Tom

Discussion

  • Tom Arn

    Tom Arn - 2002-09-24

    Logged In: YES
    user_id=462273

    I sent a fix to Guilect for verification.
    (Does not solve the WinCE ping problem!)

    Tom

     
  • A.H. Banen

    A.H. Banen - 2002-09-29

    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

     

Log in to post a comment.