You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Purcell, Scott" <sp...@ltcgroup.com> on 2001/06/11 23:29:24 UTC

Check Persistance

Hello,
Newbie modperl guy has question about the code he created today. This is the
beginning of a web site, and when the user logs in, I want to create a
socket that will remain persistent in memory until the WebServer is started
again. I do NOT want to keep opening up sockets each time this file is read.
I believe I have it, but since this is my first chunk I wrote for
persistance, I was hoping someone could give it a look.

thanks
Scott Purcell


########
use vars qw ($q $handle);
use CGI;
use strict;
use IO::Socket;
use VBMain::Config qw(%c);

$q = CGI->new;
print $q->header();

unless ($handle = &makeSocket != 0) {
    die("Cannot figure it out");
}



sub makeSocket
{
    $handle = IO::Socket::INET->new(Proto => 'tcp',
                                    PeerAddr => $c{host},
                                    PeerPort => $c{port}) or return 0;
    $handle->autoflush(1);
    print qq{<pre>Connected: $c{host}:$c{port}</pre>};

    return $handle
}