It seems like I should be looking to implement an application layer protocol to transfer data (text) between server and client, but I don't want to invent my own protocol or use one that's more complex than I need. Google searches have not resulted in a definitive answer. Is there an existing protocol I should look into?

That really depends on what you want to transfer. It looks like you've already got a basic line-based protocol, which is actually not too uncommon for simple applications, so it's a very good start. But since you say you're doing this to learn, I might suggest that writing your own protocol while reading the specifications of another existing protocol might be best.

For example, HTTP/1.0 (RFC 1945) (although it's mostly been superseded by HTTP/1.1 and grown quite complex through all sorts of extensions) can show you the basics of "one way to do it", plus you'll learn a lot about HTTP. Note that if you look at the Session Initiation Protocol (SIP, RFC 3261), one of the basics of VoIP, you'll recognize a very similar message structure as HTTP (one line for the request / response, plus headers, blank line, then content).

Based on your example messages, it looks like you're interested in something like IRC, so perhaps a read of some technical information like RFC 1459 would be helpful. For something a bit more modern, see e.g. XMPP.

Other classic protocols that are still in wide use today are e.g FTP and SMTP.


In reply to Re: TCP Server: Beyond echoing request by haukex
in thread TCP Server: Beyond echoing request by jeremywakeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.