Results 1 to 2 of 2

Thread: ThinBasic online help's TCP example

  1. #1

    Question ThinBasic online help's TCP example


    adapting this example: because it is not working for me as-is;

    '---Load Console Module
    Uses "Console"
    ' - connect to a web site
    ' - ask for a page
    ' - save it into a buffer
    ' - save the buffer into a text file
    '---Load TCP module
    '---Load File module
    '---Define some global variables and init them
    Dim MyPage As String = ""'""
    Dim MySite As String = ""
    Dim sBuffer As String
    Dim sPage   As String    
    Dim Count   As Long
    '---Get a file number
    Dim nFile   As Long = Tcp_FreeFile
    '---Open a connection
    TCP_Open(443, MySite, nFile) ' <-- *** here 80 or 443 ***
    '---Send request
    TCP_Print(nFile, "GET " & MyPage)' & " HTTPS/1.0")
    TCP_Print(nFile, "HOST: " & MySite)
    TCP_Print(nFile, "User-Agent: TCP Test using thinBasic")
    TCP_Print(nFile, "")
    '---Get back data in a loop
    INCR Count
     sBuffer = TCP_Recv(nFile, 4096)
     sPage = sPage & sBuffer
    Loop While ((Len(sBuffer) > 0) And (ERR = 0))
    '---Close the channel
    '---Save the page
    File_Save(APP_SourcePath & "Page.txt", sPage)
    PrintL "Press a key to end program"
    '---Wait for a key press
    • Have you the same issue ?

    I can't get it work with https port 443 (see

    • Does it mean that accepted values are just the four mentioned aka either 80, 25, "HTTP", or "SMTP" ?
    • Is using INet the only alternative ?
    Last edited by DirectuX; 24-10-2018 at 20:58. Reason: forgot to insert code

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Milan - Italy
    Blog Entries
    Rep Power
    Maybe my example was a bit old and confusing.
    I will try to make a better one.

    TCP/UDP module works on the transport layer (layer 4) of the OSI Model:

    That module doesn't know anything about transported data, it is just responsible of transporting and re-organizing bytes.
    So HTTP, SMTP, FTP ... are just ports to connect to.
    Successive layers of the OSI model are responsible to give a meaning to transported data.

    If you tell me what you are trying to do, maybe I get help on that.

    Eros | |
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Manual of use / thinbasic help online
    By Edcronos in forum thinBasic General
    Replies: 0
    Last Post: 30-12-2016, 15:22
  2. Online-help: Where are the modules?
    By ReneMiner in forum Fixed or cleared errors in help material
    Replies: 5
    Last Post: 29-12-2015, 12:54
  3. tB-online-interpreter-idea
    By ReneMiner in forum Suggestions/Ideas discussions
    Replies: 7
    Last Post: 10-06-2014, 10:31
  4. TAB tutorial online
    By catventure in forum T.A.B. (ThinBasic Adventure Builder)
    Replies: 3
    Last Post: 14-10-2006, 21:45

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts