Hi,
Can you eXplain the use of this line in perl
$SIG{CHLD} = sub {wait ()};
what does this do.....
this is used in an eXample for a fork call in perl...
and the main problem is this code , the program
isn't entering the accept() branch.
Creates Socket and instead of going thru the while loop
goes to neXt statement in while loop.
Code: Start
-----------------------------
use IO::Socket;
$SIG{CHLD} = sub {wait ()};
$mainSock = new IO::Socket::INET (LocalHost => 'localhost',
LocalPort => 5893,
Proto => 'tcp',
Reuse => 1
);
die "\nMain Socket could not be created. Reason: $!" unless $mainSock;
print "MAIN: Socket Creation succ\n";
while ($msgSock = $mainSock->accept())
{
print "Inside Accept";
if(!defined($child_pid = fork()))
{
die "\nCannot fork: $!";
}
if($child_pid == 0)
{
# After fork the return val. of child is 0
forkedChild($msgSock);
exit(0);
}
}
print "MAIN: End of Program\n";
sub forkedChild
{
$msgSock = $_[0];
while(defined($buffer = $msgSock->get_line()))
{
print $buffer;
}
}
------------------------------------------
Code: END
Regards
Jaswinder Singh Kohli
[EMAIL PROTECTED]
::::::::::::::::::::::::::::::::::::::::::::::::
The Uni(multi)verse is a figment of its own imagination.
-=-
When you are courting a nice girl, an hour seems like a second.
When you sit on a red-hot cinde, a second seems like an hour.
That's relativity.
Albert Einstein (1879-1955), German-American
================================================
To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject
header. Check archives at http://www.mail-archive.com/ilugd%40wpaa.org