Announcement

Collapse
No announcement yet.

Proper Include file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    There could be another drawback, as it is lockdown to port 80 as some LANs uses port 8080 ?

    Comment


    • #22
      Maybe this would be better as no specific port is assumed?


      Code:
      #COMPILE EXE
      #DIM ALL
      
      '========================
      FUNCTION PBMAIN () AS LONG
      
         LOCAL RECEIVE_BUFFER AS STRING
         LOCAL  Site$
         Site$ =  "www.google.com"
      
         LOCAL nff AS LONG
         nff = FREEFILE
      
         TRY
             ' TCP OPEN PORT 80 AT "google.com" AS #nff
               TCP OPEN "http" AT Site$ AS #nff TIMEOUT 60000
      
         CATCH
             MSGBOX " NO INTERNET"
             CLOSE #nff
             EXIT FUNCTION
         END TRY
      
         TCP PRINT #nff, "HEAD"
         TCP PRINT #nff, ""
      
         TCP RECV #nff, 4, RECEIVE_BUFFER
         IF RECEIVE_BUFFER = "HTTP" THEN
             MSGBOX "YOU HAVE INTERNET"
           ELSE
             MSGBOX "NO INTERNET"
         END IF
      
         CLOSE #nff
      
      END FUNCTION

      Comment


      • #23
        Ok, if that works for you. I cannot get your app to produce results on my system. I'm running PBWIN 10.04. I checked to see if my antivirus was blocking it. Nope

        Comment


        • #24
          ... as some LANs uses port 8080 ?
          No. LANs don't use ports. Port 80 is for communicating with http servers. 8080 is common as an alternate for 80. Like when multiple web server programs running on one computer. Also some IP address translators, and proxy servers, require browsers to make http requests at alternate port (like 8080) which is translated back to 80 on Internet side. (perhaps this is what you were refering to?)

          ref - your code in post 22 - putting "http" is the same as putting 80 in a LONG for port parameter of TCP OPEN. For a choise you will need an input; like something in COMMAND$.

          An immediate TCP RECV might happen before net traverse and server reponse time.

          Getting there!
          Dale

          Comment


          • #25
            Also in posted code. You populate nff with FREEFILE (a good thing), but the TCP OPEN still has "#1"

            TCP PRINT, TCP RECV and CLOSE are all trying use nff which was never opened,

            ((The TCP OPEN line that does use nff is commented out))
            Dale

            Comment


            • #26
              Chris, I'm thinking your looking for something like this. At any rate it works on my machine. https://forum.powerbasic.com/forum/u...net-connection
              It also deletes the cache so you do not get false positives.

              Comment


              • #27
                Thanxx a lot Jim, what a beauty !

                Comment


                • #28
                  Originally posted by Mike Doty View Post
                  sample below worked fine.

                  Code:
                  DECLARE FUNCTION IsInternetConnected IMPORT "Connect.dll" ALIAS "IsInternetConnected" () AS LONG
                  FUNCTION PBMAIN () AS LONG
                  IF ISFALSE(IsInternetConnected) THEN
                  ? "connected",,"No error"
                  ELSE
                  ? "not connected",%MB_ICONERROR,"Error"
                  END IF
                  END FUNCTION
                  Mike!!!

                  This is a gem -- fast and accurate!

                  Thank you!
                  -John


                  Comment

                  Working...
                  X