Results 1 to 2 of 2

Thread: ThinBasic online help's TCP example

  1. #1

    Question ThinBasic online help's TCP example

    Hi,

    adapting this example: https://www.thinbasic.com/public/pro...p_example1.htm 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
    
    USES "TCPUDP"
    
    
    '---Load File module
    
    USES "FILE"
    
    '---Define some global variables and init them
    
    Dim MyPage As String = "https://www.thinbasic.com/index.php"'"http://www.thinbasic.com/index.php"
    Dim MySite As String = "www.thinbasic.com"
    
     
    
    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
    
    Do                                            
    
    INCR Count
    
     sBuffer = TCP_Recv(nFile, 4096)
     sPage = sPage & sBuffer
    
    Loop While ((Len(sBuffer) > 0) And (ERR = 0))
    
     
    
    '---Close the channel
    
    TCP_Close(nFile)
    
    '---Save the page
    
    File_Save(APP_SourcePath & "Page.txt", sPage)
    
    
    
    PrintL "Press a key to end program"
    
    '---Wait for a key press
    WaitKey
    
    • Have you the same issue ?

    I can't get it work with https port 443 (see https://www.thinbasic.com/public/pro...l?tcp_open.htm)

    • 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
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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: https://en.wikipedia.org/wiki/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.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

Members who have read this thread: 2

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
  •