DiscoverQB64 ReportEpisode 4 - Networking in QB64
Episode 4 - Networking in QB64

Episode 4 - Networking in QB64

Update: 2020-07-141
Share

Description

In this episode, Fellippe and Dave talk to Luke, one of the developers maintaining QB64, about about TCP/IP communications, how to create a simple server program and a simple client program to connect to it - both locally and over the Internet.

Here are the code snippets explained in this episode:
'-------------------------------
'Sample 1: Simple HTTP request
h& = _OPENCLIENT("tcp/ip:80:alephc.xyz")
s$ = "GET /test.txt HTTP/1.0" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
PUT #h&, , s$

s$ = ""
WHILE s$ = ""
    GET #h&, , s$
WEND
PRINT s$
CLOSE #h&

'-------------------------------
'Sample 2: Split request
'-------------------------------
h& = _OPENCLIENT("tcp/ip:80:alephc.xyz")
s$ = "GET /test.tx"
PUT #h&, , s$
s$ = "t HTTP/1.0" + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10)
PUT #h&, , s$

s$ = ""
WHILE s$ = ""
    GET #h&, , s$
WEND
PRINT s$
CLOSE #h&

'-------------------------------
'Sample 3: LONG Doubler
'-------------------------------
host& = _OPENHOST("tcp/ip:9991")
DO
    c& = _OPENCONNECTION(host&)
    IF c& < 0 THEN
        PRINT "Received connection"
        DO
            GET #c&, , value&
        LOOP WHILE EOF(c&)
        PRINT "Received"; value&
        result& = value& * 2
        PUT #c&, , result&
        CLOSE #c&
    END IF
    _LIMIT 10
LOOP
CLOSE host&


'-------------------------------
'Sample 4: LONG Doubler Client
'-------------------------------
    INPUT "Enter value:", value&
    h& = _OPENCLIENT("tcp/ip:9991:localhost")
    PUT #h&, , value&
    DO
        GET #h&, , response&
    LOOP WHILE EOF(h&)
    PRINT "Response is"; response&
    CLOSE h&

Support the show (https://www.patreon.com/qb64)

Comments 
00:00
00:00
x

0.5x

0.8x

1.0x

1.25x

1.5x

2.0x

3.0x

Sleep Timer

Off

End of Episode

5 Minutes

10 Minutes

15 Minutes

30 Minutes

45 Minutes

60 Minutes

120 Minutes

Episode 4 - Networking in QB64

Episode 4 - Networking in QB64

QB64 Team