Author Topic: Monitor the health of your connection by constant PINGs  (Read 3705 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Monitor the health of your connection by constant PINGs
« on: January 31, 2019, 11:31:40 pm »
Code: QB64: [Select]
  1. DEFINT A-Z
  2. DIM buffer$(100), site$(20), pass&(20), errcount&(20)
  3.  
  4. DATA "boredpanda.com"
  5. DATA "ebay.ca"
  6. DATA "facebook.com"
  7. DATA "gmail.com"
  8. DATA "google.ca"
  9. DATA "kijiji.ca"
  10. DATA "mail.com"
  11. DATA "netgear.com"
  12. DATA "purple.com"
  13. DATA "qb64.org"
  14. DATA "radio.net"
  15. DATA "scitechdaily.com"
  16. DATA "wikipedia.org"
  17. DATA "yahoo.com"
  18. DATA "youtube.com"
  19.  
  20. begin:
  21.     READ p$
  22.     IF p$ = "end" THEN EXIT DO
  23.     numsites = numsites + 1
  24.     site$(numsites) = p$
  25.  
  26.     currentsite = currentsite + 1 + (currentsite = numsites) * numsites
  27.     pass&(currentsite) = pass&(currentsite) + 1
  28.     SHELL _HIDE "CMD /c ping www." + site$(currentsite) + " -n 1 -w 500 >temp.txt"
  29.     FOR row = 18 TO 25
  30.         LOCATE row, 1: PRINT SPACE$(80);
  31.     NEXT row
  32.     OPEN "temp.txt" FOR INPUT AS #1
  33.     n = 0: errflag = 1: myrow = 19
  34.     WHILE NOT (EOF(1))
  35.         n = n + 1
  36.         LINE INPUT #1, buffer$(n)
  37.         lb = LEN(buffer$(n))
  38.         IF (lb > 0) AND (myrow < 26) THEN
  39.             LOCATE myrow, 1: PRINT LEFT$(buffer$(n), 79);
  40.             myrow = myrow + 1
  41.         END IF
  42.         IF LEFT$(buffer$(n), 10) = "Reply from" THEN errflag = 0
  43.     WEND
  44.     CLOSE #1
  45.     LOCATE currentsite + 2, 48: PRINT SPACE$(32);
  46.     IF errflag THEN
  47.         'SOUND 200, 1
  48.         errcount&(currentsite) = errcount&(currentsite) + 1
  49.     END IF
  50.     GOSUB Stats
  51.     wait1! = ((TIMER + 1 - (currentsite = numsites) * 1) MOD 86400) - RND
  52.     DO
  53.         xx = (xx + 1) MOD 4
  54.         LOCATE currentsite + 2, 21: PRINT MID$("|/-\", xx + 1, 1);
  55.         wait2! = TIMER + .2: IF wait2! > 86400 THEN wait2! = 0
  56.         DO: _LIMIT 10
  57.             i$ = INKEY$
  58.             IF i$ = CHR$(27) THEN EXIT DO
  59.         LOOP UNTIL TIMER > wait2!
  60.     LOOP UNTIL (i$ = CHR$(27)) OR (TIMER > wait1!)
  61.     LOCATE currentsite + 2, 21: PRINT " ":
  62. LOOP UNTIL i$ = CHR$(27)
  63.  
  64. Stats:
  65. LOCATE 1, 1: PRINT SPACE$(22); "Good    Bad      Loss %"
  66. LOCATE 2, 1: PRINT SPACE$(22); "----    ----     ------"
  67. LOCATE currentsite + 2, 1: PRINT site$(currentsite); TAB(22);
  68. good& = pass&(currentsite) - errcount&(currentsite)
  69. PRINT good&; TAB(32);
  70. PRINT errcount&(currentsite); TAB(39);
  71. IF good& = 0 THEN loss = 100 ELSE loss = INT(errcount&(currentsite) * 100 / pass&(currentsite) + .5)
  72. PRINT loss;
  73. GOSUB bar
  74.  
  75. bar:
  76. x = loss / 100 * 30
  77. DEF SEG = &HB800
  78. FOR i = 1 TO 30
  79.     a = (currentsite + 1) * 160 + (i + 46) * 2 + 1
  80.     IF x < i THEN c = 2 ELSE c = 4
  81.     IF PEEK(a - 1) = 32 THEN POKE (a - 1), ASC("-")
  82.     POKE a, c
  83.  
  84.  
  85.  
« Last Edit: February 01, 2019, 02:13:31 am by Richard Frost »
It works better if you plug it in.