I'm not really sure what you're suggesting. I'm using IO::Socket to create the socket. Now I want to draw data from it by calling a function. Here is how it's created:
$sock = new IO::Socket::INET(
LocalHost => $myip,
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket :$!";
STDOUT->autoflush(1);
#main loop begin
{
while (($new_sock, $c_addr) = $sock->accept()) {
($client_port, $c_ip) = sockaddr_in($c_addr);
$client_ipnum = inet_ntoa($c_ip);
$client_host = gethostbyaddr($c_ip, AF_INET);
next if $kid = fork;
die "fork: $!" unless defined $kid;
close $sock;
if (&readfromsocket(*new_sock)){
In the subroutine I could do this:
if (defined($lineread = <$new_sock>)) {whatever}
But I want to be able to use another var name in the subroutine.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.