huchister has asked for the wisdom of the Perl Monks concerning the following question:

Greeting monks,

I have minor question regard with IO::Socket::SSL issue.

I am working on building Net WebSocket Application using Net::WebSocket::Server module.

http://search.cpan.org/~topaz/Net-WebSocket-Server-0.001003/lib/Net/WebSocket/Server.pm

I was successfully building websocket server, but little concern about building IO::Socket::SSL objects.

It seems everytime when handshake occurs, its building new IO::Socket::SSL object for clients with new Symbol creation. When I dump socket object variable in log file it output as follows:

$VAR1 = bless( \*Symbol::GEN67, 'IO::Socket::SSL' );

My concern is this GEN # number is keep increasing (ex. Symbol::GEN68, Symbol::GEN69, Symbol::GEN70 .... so forth) no matter what. I don't know whether this Symbol::GEN object should be deleted or not.

I wonder if anybody can enlighten me in some aspect of using IO::Socket::SSL. What would be proper way to close / shutdown its service. Does it closes automatically if socket isn't being used? Should I concern about symbol # increases?

For your record, I am using Steffen Ullrich's version of IO::Socket::SSL

http://search.cpan.org/dist/IO-Socket-SSL/lib/IO/Socket/SSL.pod<br><br> Thanks!

Replies are listed 'Best First'.
Re: IO::Socket::SSL & Net::Websocket::Server Question
by zentara (Cardinal) on Jul 29, 2014 at 17:47 UTC
    I'm not sure it will work in your case, but have you tried to clean out the IO::Socket::SSL object? From "perldoc -q clear": Specifically look at the
    Symbol::delete_package() function .

    Found in /usr/lib/perl5/5.20.0/pod/perlfaq7.pod How do I clear a package? Use this code, provided by Mark-Jason Dominus: sub scrub_package { no strict 'refs'; my $pack = shift; die "Shouldn't delete main package" if $pack eq "" || $pack eq "main"; my $stash = *{$pack . '::'}{HASH}; my $name; foreach $name (keys %$stash) { my $fullname = $pack . '::' . $name; # Get rid of everything with that name. undef $$fullname; undef @$fullname; undef %$fullname; undef &$fullname; undef *$fullname; } } # Or, if you're using a recent release of Perl, you can just use the # Symbol::delete_package() function instead.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      But the globs numbers still wont be reset to 0, as you saw :)
        Symbol::gensym() which is used here just uses a global counter to make sure to never create the same symbol twice. So even if the previous symbols are no longer valid it will not reset the counter. No need to worry.
Re: IO::Socket::SSL & Net::Websocket::Server Question
by Anonymous Monk on Jul 29, 2014 at 17:29 UTC
    I don't think it's a problem.
    perl -MSymbol -MData::Dumper -wE ' {my $x=gensym; print Dumper $x}; {my $y=gensym; print Dumper $y}; my $z=gensym; print Dumper $z; print $x, $y'
    Output:
    Name "main::x" used only once: possible typo at -e line 1. Name "main::y" used only once: possible typo at -e line 1. $VAR1 = \*Symbol::GEN0; $VAR1 = \*Symbol::GEN1; $VAR1 = \*Symbol::GEN2; Use of uninitialized value $x in print at -e line 1. Use of uninitialized value $y in print at -e line 1.
    That's just how Symbol generates globs, I think.
      Thanks. I was bit worried whether my script takes up unnecessary variable or eat up any memory cause of this.