Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Perl: the Markov chain saw
 
PerlMonks  

Re: regarding session in CGI

by hanenkamp (Pilgrim)
on Dec 17, 2003 at 09:41 UTC ( [id://315276]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to regarding session in CGI

You're going to have a problem doing this since your CGIs are going to be run each as a separate process. Therefore, between requests, your telnet object is being serialized to disk, but the socket will be closed when the application exists. Therefore, the second request no longer refers to an active socket.

There are a number of work-arounds, though. You could run your scripts inside of mod_perl and save your telnet information in memeory to keep the socket alive between requests. Another solution would be to have a separate process running as a sort of middleware to actually manage the telnet connection and then use IPC to tell the persistent script what to do--a named pipe could work well here.

Replies are listed 'Best First'.
Re: Re: regarding session in CGI
by mnsbb (Initiate) on Dec 17, 2003 at 10:52 UTC
    thanks a lot hanenkamp. I m new to perl and cgi. i m little confused with mod_perl. Hence i beseech u to give me a clear picture of where mod_perl sits in my code, or please refer me some clear documents in gaining knowledge about that. Thanks again. mnsbb
      Hi mnsbb,
      Don't worry, you're not alone...
      ...or please refer me some clear documents in gaining knowledge about that...
      I'm looking at them right now which can be found at http://perl.apache.org. I too am struggling a bit with mod_perl but the benefits seem to be worth it in the long run.

      Actually, mod_perl is just a platform within which you run your code. See http://perl.apache.org/ for details on mod_perl. Essentially, your CGI scripts can be used as is to run inside a special mod_perl handler process. Or you can rewrite your scripts to use mod_perl's handler API directly.

      Thus, you can probably use your code as is within mod_perl (though, you'll still need some modification to cache your telnet connection) or you can rewrite it to use the mod_perl framework directly, if you prefer.

        Hi hanenkemp and barrd, I got it working and now the response time is 2 seconds. Thanks a lot.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://315276]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.