I test everything you mention Bill. Actually it was not really a problem but an understanding that you can not get away using simple approach
while ($socket) ... or ... $socket->recv($var, 1024) ...
when you want complex things like.
-- hey client, I am going to send you a file so big
++ ok server
You should be able to just send the file with a proper header saying what it is.
-- now lets exchange some small control messages
++ ok server
Again, you don't have to tell the server what you're going to do,
just prepend a header saying what it is.
-- now get a big serialized data structure
++ not everything is defined
Asking for something back - that needs a request. You have to be prepared
to then receive the data back.
-- ops client I did not like your answer, wait for three messages for me
That's not something I would do. Normally, you would just re-request the
data, but you can implement whatever you need obviously.
Obviously you have to have a control structure of some kind if you're doing
more than one thing in the server, but the code to read the socket can still
be simple before farming the record off to the proper sub to handle it.
I've done similar logic for a PTP app where two or more users can share a
directory on their disk with others. Basically I implemented logic to connect
to a master server to find other sharers; logic to connect to a share server
and get a list of files being shared; logic to register with the master server;
logic to retrieve a file from the sharer; a GUI to show sharers directories
and active xfers, etc. in basically two tasks (a client and a server).
I wrote a layer on top of TCP/IP Sockets in my case to create a record structure
to pass between them with a common record header structure. I used select
and sysread/syswrite for my I/O on Doze (harder than UNIX).
Good luck doing what you're doing - feel free to ask for any further assistance.