Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Do you know where your variables are?
 
PerlMonks  

Re^4: Creating Socket Connections that are persistent across multiple page loads in a single web session

by unlinker (Monk)
on Jan 05, 2011 at 09:46 UTC ( #880554=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Creating Socket Connections that are persistent across multiple page loads in a single web session
in thread Creating Socket Connections that are persistent across multiple page loads in a single web session

Thank you for being patient, but sorry, I dont get it (not my best day, obviously:)). Are you suggesting that I serialize the socket and store it as a session scalar and deserialize it back in the next pass of the same session? I doubt that you can do it with sockets.


Comment on Re^4: Creating Socket Connections that are persistent across multiple page loads in a single web session
Re^5: Creating Socket Connections that are persistent across multiple page loads in a single web session
by Corion (Pope) on Jan 05, 2011 at 09:49 UTC

    Yes. You cannot serialize sockets. So you need a persistent program on your server that keeps the socket open. That persistent program gives the client ("web browser") a token ("a session id", "a cookie") that associates the socket with the client. When some client connects again to your server process and presents the appropriate token, you know which connection to reuse.

      OK! Let me give implementing this a shot. Thank you for your patience :)

        I have done this using the POE framework. I keep a persistent connection to two tcp servers and marshal all CGI connections through them, keeping track using unique Ids and using JSON for passing the data between them.

        use POE qw(Component::Schedule Filter::Reference Component::Server::TCP Component::Client::TCP Filter::Line Component::Log4perl Component::Daemon );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://880554]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-04-21 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls