PRINT "Connecting to host...";
'this is the host program
PRINT "Starting host...";
PRINT "Listening on port 60710..."
a$ = "MSG>HELLO!"
Send client, a$
PRINT "Connected. Waiting for requests..."
incomingData$ = ""
GET #client
, , incomingData$
stream$ = stream$ + incomingData$
'process requests from the client
'custom format: REQUEST>data to be sent<END>
'separate command, data and remove this command from the stream
thisData$
= LEFT$(stream$
, INSTR(stream$
, "<END>") - 1) stream$
= MID$(stream$
, INSTR(stream$
, "<END>") + 5) thisCommand$
= LEFT$(thisData$
, INSTR(thisData$
, ">") - 1) thisCommand$ = thisData$
thisData$
= MID$(thisData$
, LEN(thisCommand$
) + 2)
Send client, myData$
Send client, myData$
myData$ = "MSG>Time flies like bananas."
Send client, myData$
PRINT "Message from client: "; thisData$
myData$ = "MSG>BYE!"
Send client, myData$
client = 0
mouseDown = -1
mouseDown = 0
LINE (oldMx
, oldMy
)-(mX
, mY
) oldMx = mX
oldMy = mY
oldMx = mX
oldMy = mY
'this is the client program
PRINT "Click around to send mouse data; hit space to enter command..."
incomingData$ = ""
GET #host
, , incomingData$
stream$ = stream$ + incomingData$
'process responses from the host
'custom format: RESPONSE>data received<END>
'separate command, data and remove this command from the stream
thisData$
= LEFT$(stream$
, INSTR(stream$
, "<END>") - 1) thisCommand$
= LEFT$(thisData$
, INSTR(thisData$
, ">") - 1) thisData$
= MID$(thisData$
, LEN(thisCommand$
) + 2) stream$
= MID$(stream$
, INSTR(stream$
, "<END>") + 5)
PRINT "Message from host: "; thisData$
oldMx = mX
oldMy = mY
c$
= "MOUSEX>" + MKI$(mX
) Send host, c$
c$
= "MOUSEY>" + MKI$(mY
) Send host, c$
c$
= "MOUSEDOWN>" + MKI$(1) Send host, c$
mouseDown = -1
c$
= "MOUSEUP>" + MKI$(1) Send host, c$
mouseDown = 0
INPUT "Command (TIME, DATE, WISDOM, MSG>your message, BYE:", c$
Send host, c$
c$ = ""
SUB Send
(channel
, __theData$
) theData$ = __theData$ + "<END>"