
Sign up to save your podcasts
Or
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&
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&