I honestly shouldn't be playing like that, cause I'm not quite sure how it works, only simply that it does. So I am assuming you could do something similar by storing it in a hash or even in an array and passing the hash/array around and then pulling the reference to the socket back out of the data structure.# # initialization # $self->{'sock'} = IO::Socket::INET->new( args => 'go_here', ) || die "Cant create socket\nReason: $!\n"; # #retrieval for use # $sock = $obj->_get_sock(); sub _get_sock { return($_[0]->{'sock'}); }
Edit: I should clarify a little I guess, I do know how the code works, and what I am passing around, and even what is going on in _get_sock, Im just not overly familiar with OOP. I use it, but I don't understand all of the inner workings of perl OOP, and there are better ways to play with sockets. It was simply a shotgun approach, which proved I could prototype what I wanted and get a working model. I probably should have read your code, as opposed to simply assuming you wanted to know how to pass a socket around.$sock = IO::Socket::INET->new( args => 'go_here', ) || die "blah\n$!\n"; $sock_ref = \$sock; some_func($sock_ref); sub some_func { $ref = shift; $sock = ${$ref}; $line = <$sock>; }
In reply to Re: Passing IO::Socket::INET
by l2kashe
in thread Passing IO::Socket::INET
by jk2addict
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |