Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
So is there a way to keep the client connection persistent and only 'close' when the client is finished?

In general, tcp connections are persistent. That is, they only disconnect when either the client or server explicitly choose to do so. However, there is usually an 'inactivity' timeout period, often set (for historical reasons) to 900 seconds, though that can be modified at either end of the connection.

If you have reason to believe that your client might not (naturally) use the connection frequently enough to prevent the inactivity timeout from kicking, then the usual thing to do is add a 'heartbeat' message to your protocol. This takes the form of a do-nothing message or exchange, that can be initiated from either the client or the server, at some regular period less than the prevailing timeout.

And if the connection is persistent, would that prevent other clients from connecting?

That depends upon the implementation of the server.

Well written servers -- whether selecting, pre-forking or threaded -- can easily maintain concurrent, persistent connections with many clients. Hundreds or even thousands of concurrent connections are possible for low-volume protocols, but it obviously depends upon the design and implementation of the server; the volume of traffic per client; the capacity of the server hardware; and the bandwidth of the servers network connections.

But that's all very general information. To get better answers to your questions you'll need to describe your application in more detail; and outline what problems you are either experiencing or are anticipate encountering.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re: How to maintain a persistent connection over sockets? by BrowserUk
in thread How to maintain a persistent connection over sockets? by flexvault

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 admiring the Monastery: (3)
As of 2024-04-19 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found