DS_Listen only establishes that you want to accept a connection.
Once the connection has been established, DS_Recieve recieves the data that comes in.
Forgive me if I over-simplify, but I'm trying to cover the broadest audience possible:
Think of it like a telephone. DS_Listen tells the computer to wait until the phone rings and then answer it. DS_Connect tells the computer to dial a number. DS_Recieve is like the earpiece, you get data from DS_Recieve. DS_Send is like the mouthpiece, sending out the data you want to send. It would not be practical to use DS_Listen to accept connections
and data b/c each time it would have to hang up the phone, then the client would have to dial again, then the server would have to answer the phone again, then get more data.
So from a server's point of view, this is what happens:
Server waits for the phone to ring. (DS_Listen(9876))
Once the phone rings, server picks up the reciever and you are in a call.
Server says, "Hello, I am the server." (DS_Send("Ready"))
Server waits for a response. (loop until DS_Recieve != "NULL")
Server hears, "Where is the pie?" (a$=DS_Recieve()) and a$="Rqst#pie")
Server looks up the position of pie.
Server says, "The pie is at 45,27,33" (DS_Send("PosPie#45,27,33"))
Server waits for more conversation. (loop until DS_Recieve != "NULL")
more conversation....
Server says, "I'm tired of talking to you, goodbye." (DS_Send("kill"))
Server quits or waits for another connection.
from the client's point of view:
Client dials server's number. (DS_Connect("48.57.33.98",9876)
Client waits for the server to answer.
Client hears the server pick up the phone.
Client waits for the server to say something. (loop until DS_Recieve != "NULL")
Client hears, "Hello, I am the server." (a$=DS_Recieve and a$="Ready")
Client says, "Where is the pie?" (DS_Send("Rqst#pie"))
Client waits for the server to say something. (loop until DS_Recieve != "NULL")
Client hears "The pie is at 45,27,33", (a$=DS_Recieve and a$="PosPie#45,27,33")
more conversation takes place
Client hears "I'm tired of talking to you, goodbye" (a$=DS_Recieve and a$="kill")
Client hangs up, quits, or dials again.
How you format your messages doesn't matter, like instead of saying "PosPie#45,27,33" you could also say "position of pie is at 45,27,33" or "F6002D001B0021" where F6 is the command number in hex, 002D is hex for 45, etc etc. It's best send the smallest amount of characters possible to help your programs communicate faster. It doesn't matter much for peer-to-peer connections like the ones currently supported by this plugin, but later
if I implimint true server-like commands and you get into dozens, hundreds or even thousands of connections, you will appreciate every single byte you can squeeze out of a packet. When I impliment the ability to send/recieve raw, that will further decrease packet sizes.
I am considering adding a DS_MsgWait to check for messages waiting to be recieved instead of having to always DS_Recieve and parse to see if it's data or null.