Fellow Monks,

a (Mason-based) webapp connects to a backend server via IO::Socket::INET. Now I would like to make that connection persistent for the session. unfortunately, simply pouring the client object into the session storage doesn't work, as this immediately complains:

The handle is created the usual way - I think.

$handle = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => $host, PeerPort => $port, Blocking => $blocking, );

But if I want to store it in a session, like this (Dumper output)

'one-session-key' => bless( { ... '_handle' => bless( \*Symbol::GEN40, 'IO::Socket::INET' + ), ...

I see this error

(in cleanup) Can't store GLOB items at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/_freeze.al) line 339, <GEN40> line 7, at /usr/lib64/perl5/vendor_perl/5.8.8/Apache/Session/Serialize/St +orable.pm line 21

I have read here about why this doesn't work and why some people think it doesn't make sense to try to achieve that persistence. Well - for me the reason is, that when the traffic gets high, I would prefer for a session not always to:

Actually I'd be pretty happy if one could omit the 1st and 3rd point, because they are simply performance killers during a session. Now what I have tried;

Circumventing the "Storable cannot store GLOB" problem by transfering bless( \*Symbol::GEN40, 'IO::Socket::INET' ), to a string and later evaluating that actually DOES work, but as I've been told this doesn't keep up the connection, instead it recreates just some glob. The result being a program that astonishingle DOES still work, but I see connections being established and terminated (probably when the last reference to the glob vanishes).

So what could one do? My next ideas would be:

1. some kind of mini-persistent-proxy on the frontend side that would keep up the persistent connections under some accessible index (and the index number of course easily storable in session data.

2. and/or by somehow tieing these sockets to the filesystem (socket files) and using them as the proxy. No idea HOW to do that, just an Idea, because I know there are socket "files".

What would you suggest?

Bye
 PetaMem
    All Perl:   MT, NLP, NLU


In reply to How to keep network connection persistent during session? by PetaMem

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.