Author Topic: QB64 REPORT S01E04: "Networking in QB64"  (Read 3347 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
QB64 REPORT S01E04: "Networking in QB64"
« on: July 14, 2020, 12:48:06 am »
 [ You are not allowed to view this attachment ]  

This is the discussion thread for Episode 4 of QB64 Report, which is now available.

🔊 This time we talk to @luke, who's one of QB64's developers, and learn a lot about TCP/IP communications and networking in QB64.

Check it out at http://podcast.qb64.org and also in all major podcast providers.

I'll share the YouTube version here soon.

FellippeHeitor

  • Guest
Re: QB64 REPORT S01E04: "Networking in QB64"
« Reply #1 on: July 14, 2020, 12:55:53 am »
  • Best Answer
  • These are the samples discussed in the episode:

    Code: QB64: [Select]
    1. '-------------------------------
    2. 'Sample 1: Simple HTTP request
    3. h& = _OPENCLIENT("tcp/ip:80:alephc.xyz")
    4. s$ = "GET /test.txt HTTP/1.0" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
    5. PUT #h&, , s$
    6.  
    7. s$ = ""
    8. WHILE s$ = ""
    9.     GET #h&, , s$
    10. CLOSE #h&

    Code: QB64: [Select]
    1. '-------------------------------
    2. 'Sample 2: Split request
    3. '-------------------------------
    4. h& = _OPENCLIENT("tcp/ip:80:alephc.xyz")
    5. s$ = "GET /test.tx"
    6. PUT #h&, , s$
    7. s$ = "t HTTP/1.0" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
    8. PUT #h&, , s$
    9.  
    10. s$ = ""
    11. WHILE s$ = ""
    12.     GET #h&, , s$
    13. CLOSE #h&

    Code: QB64: [Select]
    1. '-------------------------------
    2. 'Sample 3: LONG Doubler
    3. '-------------------------------
    4. host& = _OPENHOST("tcp/ip:9991")
    5.     c& = _OPENCONNECTION(host&)
    6.     IF c& < 0 THEN
    7.         PRINT "Received connection"
    8.         DO
    9.             GET #c&, , value&
    10.         LOOP WHILE EOF(c&)
    11.         PRINT "Received"; value&
    12.         result& = value& * 2
    13.         PUT #c&, , result&
    14.         CLOSE #c&
    15.     END IF
    16.     _LIMIT 10
    17. CLOSE host&

    Code: QB64: [Select]
    1. '-------------------------------
    2. 'Sample 4: LONG Doubler Client
    3. '-------------------------------
    4.     INPUT "Enter value:", value&
    5.     h& = _OPENCLIENT("tcp/ip:9991:localhost")
    6.     PUT #h&, , value&
    7.     DO
    8.         GET #h&, , response&
    9.     LOOP WHILE EOF(h&)
    10.     PRINT "Response is"; response&
    11.     CLOSE h&

    Offline Ashish

    • Forum Resident
    • Posts: 630
    • Never Give Up!
      • View Profile
    Re: QB64 REPORT S01E04: "Networking in QB64"
    « Reply #2 on: July 14, 2020, 01:47:32 am »
  • Best Answer
  • Great! :)
    if (Me.success) {Me.improve()} else {Me.tryAgain()}


    My Projects - https://github.com/AshishKingdom?tab=repositories
    OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

    Offline Qwerkey

    • Forum Resident
    • Posts: 755
      • View Profile
    Re: QB64 REPORT S01E04: "Networking in QB64"
    « Reply #3 on: July 14, 2020, 04:46:30 am »
  • Best Answer
  • @luke definitely gets the Tim Berners-Lee award.  It is amazing that QB64 can do all that stuff.  (It's all a bit beyond my skill level, I think that I'll be sticking with _MAPTRIANGLE).

    FellippeHeitor

    • Guest
    Re: QB64 REPORT S01E04: "Networking in QB64"
    « Reply #4 on: July 14, 2020, 05:41:43 am »
  • Best Answer
  • Here's the YouTube version: