Results 1 to 2 of 2

Thread: ThinBasic online help's TCP example

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    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

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: 0

There are no members to list at the moment.

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
  •