Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear Monks,

I'm in the process (no pun intended) of writing a forking server. The purpose of the server is to read data from a serial port and write that data to a socket. I'd like to handle several simultaneous clients (all receiving the same data from the serial port). In the future clients will have the option of writing to the serial port via the socket however, that's not in the plan for version 1. BTW Lincoln Stein's book is excellent for anyone interested in network programming using Perl.

My problem is (or will be) access to the serial port (since only one process can access the port at any given time). Therefore I'm in search of design advice. My initial though was to divide the application into two main components:

1) The first component handles serial port I/O: Reading data from the port and writing data to the port.

2) The second component handles socket I/O: Writing data to the socket and reading data from the socket.

Assuming this is a valid design both components will need to talk to each other (pass data back and forth). I'm looking for an elegant solution (or design pattern) that will allow the "serial" component and the "socket" to pass data back and forth. Ideally I rather not have the "serial" component know anything about "clients" that need the data. Rather I'd like the "serial" component to write to some shared memory structure (for example) and then the "socket" component reads from that shared structure and writes the data to the clients.

Does anyone have any helpful design advice? Apologies for the long message.


In reply to Design Advice: Reading data from a serial port and writing it to multiple sockets. by jmurphy

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2023-09-25 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?