02-16-2025, 01:18 AM
(This post was last modified: 02-16-2025, 01:26 AM by TheLastTMan.)
hi this is my first post. really if you want you can call me Abe, short for my real name.
there is very little documentation about this and I have been experimenting on my own but have been having problems.
i recently got interested in qb64 because it looks good more than anything else, i never used the original qb. since qb64 does not support multithreading i was looking at the wiki and i think tcp/ip might be the option. it would not be multithreading but multiprocessing but something
is something. so i have this.
Server.bas
Client.bas
apparently the part where I send the data works, but when I receive them in the client, something is wrong.
I don't even know if the part where I manipulate the array is well done. I would like to know if you could help me to know what is wrong, I would accept any feedback, thanks.
I don't know if I'm supposed to post this like this
there is very little documentation about this and I have been experimenting on my own but have been having problems.
i recently got interested in qb64 because it looks good more than anything else, i never used the original qb. since qb64 does not support multithreading i was looking at the wiki and i think tcp/ip might be the option. it would not be multithreading but multiprocessing but something
is something. so i have this.
Server.bas
Code: (Select All)
_TITLE "Server"
''$SCREENHIDE
REM'$CONSOLE:ONLY
'$DYNAMIC
_DEFINE A-Z AS LONG
OPTION _EXPLICITARRAY
SCREEN 0
DIM SENDEDLONGSG(1 TO 1)
DIM SENDEDFLOATG#(1 TO 1)
DIM SHARED WWW AS STRING * 3
HOST = _OPENHOST("TCP/IP:5000")
DO
CLIENT = _OPENCONNECTION(HOST)
IF CLIENT <> 0 THEN
GET #CLIENT, 1, WWW$
PRINT "SIMPLE REQUEST"
WWW$ = UCASE$(WWW$)
SELECT CASE WWW$
CASE "GSL": D = UBOUND(SENDEDLONGSG): _
GET #CLIENT, , SENDEDLONGSG(D): PRINT SENDEDLONGSG(D): _
REDIM _PRESERVE SENDEDLONGSG(D + 1) 'GAME SEND LONG"
CASE "GRL":_
D = LBOUND(SENDEDLONGSG): _
PUT #CLIENT, , SENDEDLONGSG(D): PRINT SENDEDLONGSG(D): _
Z = UBOUND(SENDEDLONGSG): _
if Z <> D then: FOR x = 0 TO Z STEP 1: SWAP SENDEDLONGSG(D), SENDEDLONGSG(x): NEXT: _
REDIM _PRESERVE SENDEDLONGSG(Z - 1): 'GAME RECEIVE LONG
CASE "GSD": D = UBOUND(SENDEDFLOATG#): _
GET #CLIENT, , SENDEDFLOATG#(D): _
REDIM _PRESERVE SENDEDFLOATG#(D + 1) 'GAME SEND DOUBLE"
CASE "GRF":_
D = LBOUND(SENDEDFLOATG#): _
PUT #CLIENT, , SENDEDFLOATG#(D): _
Z = UBOUND(SENDEDFLOATG#): _
IF Z<>D THEN : FOR x = 0 TO Z STEP 1: SWAP SENDEDFLOATG#(D), SENDEDFLOATG#(x): NEXT: _
REDIM _PRESERVE SENDEDFLOATG#(Z - 1) 'GAME RECEIVE DOUBLE
CASE ELSE: PRINT "IDK"
END SELECT
END IF
CLOSE CLIENT
_LIMIT 20
LOOP UNTIL UCASE$(INKEY$) = "Q"
SYSTEM 0
Client.bas
Code: (Select All)
_TITLE "Client"
_DEFINE A-Z AS LONG
X = _OPENCLIENT("TCP/IP:5000:localhost")
IF X <> 0 THEN
D$ = "GSL"
PUT #X, , D$
TOSEND = 80
PRINT TOSEND
PUT #X, , TOSEND
_DELAY 1
CLOSE X
ELSE
PRINT "error no server"
_DELAY 1
SYSTEM 1
END IF
X = _OPENCLIENT("TCP/IP:5000:localhost")
IF X <> 0 THEN
D$ = "GRL"
TOSEND = -1
PUT #X, , D$
GET #X, , TOSEND
PRINT TOSEND
_DELAY 1
CLOSE X
END IF
apparently the part where I send the data works, but when I receive them in the client, something is wrong.
I don't even know if the part where I manipulate the array is well done. I would like to know if you could help me to know what is wrong, I would accept any feedback, thanks.
I don't know if I'm supposed to post this like this