Coruscate has asked for the wisdom of the Perl Monks concerning the following question:
Idea #1: XML Tagged
Use an xml-based interface for communications. Every time the client or server wishes to say something, they pass along a block of text such as the below example. The server sends the first block to the client, requesting a password. The server then waits for a response.
# server sends to client <command name="get_passwd"> Please enter your password: </command> # client sending to server <command name="text_data"> example_password </command>
Idea #2: Fixed-Length Communication
Using a fixed-length protocol seems simple to me, so I must be missing something. I was thinking maybe of following the idea of the 'content-length' from HTTP. The example below captures my thoughts pretty well I think. The first two chars show the length of the command in 2-digit form ('get_passwd' is 10 chars long). Following the command is a 4-digit number specifying the length of the data to follow (I figure 9999 is the longest I'll ever send :P).
# server sends to client. syswrite( $client, "10get_passwd0027Please enter your password:" ); # client reads from server my ($len, $cmd, $data); sysread($server, $len, 2); sysread($server, $cmd, $len); sysread($server, $len, 4); sysread($server, $data, $len); # $cmd eq 'get_passwd' # this is # $data eq 'Please enter your password:' # correct, right?
So are my ideas out of this world in a bad way or do I have a good brainwave or two focused on this? Any insights would be greatly appreciated and welcomed with wide open arms. Slaps across the face for stupid thoughts are welcome as well :)
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Choosing a client/server protocol
by TVSET (Chaplain) on Jul 07, 2003 at 20:32 UTC | |
|
Re: Choosing a client/server protocol
by Thelonius (Priest) on Jul 07, 2003 at 21:06 UTC | |
|
Re: Choosing a client/server protocol
by sauoq (Abbot) on Jul 07, 2003 at 20:37 UTC | |
by Coruscate (Sexton) on Jul 07, 2003 at 20:47 UTC | |
by sauoq (Abbot) on Jul 07, 2003 at 23:14 UTC | |
|
Re: Choosing a client/server protocol
by waswas-fng (Curate) on Jul 07, 2003 at 21:28 UTC | |
|
Re: Choosing a client/server protocol
by zentara (Cardinal) on Jul 08, 2003 at 16:30 UTC |