Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

First I would recommend having a look at some generic solutions on CPAN, so that you can prototype quickly different approaches: some good ones are Net::Server, IO::Multiplex, IO::SessionSet and IO::SessionData in the lib directory of the perl network programming site (for non-blocking sockets in case you cannot trust your clients which is almost always the case ;))

Secondly if you maintain lots of open connections a select loop might be the way to go. Multiplexing on a few "select-loop " servers could be used to make the approach more scalable ( a request is sent to one of the children in the pool, and that child does the accept and adds the descriptor to the "select" set).

Finally studying part of the code of aproxy (a small TCP port forwarder) could be useful too

btw which platform are you on?

update Humm then there is the question of your bidirectional protocol. It is easy to do that part wrongly. I would suggest a fork for "each request to a connected client" (you need the socket descriptor of that client) IOW a fork for each server write... with COW schemes this does not have to be so costly. You could even prototype with doing a fork-exec of scripts in a server-request/ directory. It all depends on the average time of the request/answer (and your protocol). You'll need also to monitor the number of processes.

cheers --stephan


In reply to Re: TCP Socket, Forking, Memory exhaustion by sgt
in thread TCP Socket, Forking, Memory exhaustion by asuter

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?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found