Hi everyone.

I'm in the process of designing (and eventually building) an "interface" HTTP service. The idea is that this is a HTTP front-end to a traditional socket-server application. Hopefully the ASCII art below will illustrate what I'm trying to achieve.

,--------------.  ,---------------.  
| HTTP Request |  | HTTP Response | A
`--------------'  `---------------'  
        |               ^            
        |               |           B
        v               |            
,---------------------------------.  
|          Web Server             | C
`----- | --------------- ^ -------'  
       |                 |          D
,----- v --------------- | -------.  
|    Pool of socket connections   | E
`---------------------------------'  
      |  |  |       ^  ^  ^          
      |  |  |       |  |  |         F
      v  v  v       |  |  |          
,---------------------------------.  
| Multi-threaded backend system   | G
`---------------------------------'  

The point of this exercise is that I need to provide a HTTP front-end to the backend system (G). This system has a socket interface (e.g. listens on port 4567), and is designed to have one, long running, request-response stream (however it is multi-threaded, and can support multiple connections). The connection to this system (F) is a proprietary TCP/IP protocol. I need to provide a standard HTTP interface (B) to this application.

The crux of my query is this: how would you recommend implementing steps C, D and E? There are no really complicated translations needed. All messages are ASCII (text/plain), and I don't need to wrap HTML around or anything else. It is really just a translation from one protocol to another (with a very thin layer of logic to rewrite message headers).

The options I have thought of so far are as follows:

This is a common enough thing to want to implement, I'm just wondering if anyone can share any "gotchas" or suggestions about which way to go. Links to other people's implementations are just as welcome as any of your own personal experiences.

Thank you for your time. It is much appreciated. :-)

Cheers,

-- Dave :-)


$q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print

In reply to HTTP server guidance by DaveH

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.