V
vikrant
Hi
I have written a code for Listening socket(Server) that serve multiple
clients request.The Socket(Server) accept the data from clients and send
back them the same data for validation.
But,I am facing a problem while running the following code .The code
creating a Zombie for each client request.
-----------------------------------------------------------------
#!/usr/bin/perl
use IO::Select;
use IO::Socket::INET;
#LISTENING SOCKET
$sListening_Socket = new IO::Socket::INET (LocalPort => 36545,
Proto => "tcp",
Listen => 4,
Type => SOCK_STREAM)
or die "Could not create socket";
REQUEST:
while ($sNew_Socket = $sListening_Socket->accept())
{
if($iChild_Pid=fork) #Check the Child Process ID
{
close ($sNew_Socket); #Parent closes unused handle
next REQUEST;
} defined($iChild_Pid) or die "Cannot fork";
close ($sListening_Socket); #Child closes unused Handle
$obSelected_Socket = IO::Select->new($sNew_Socket);
while( $obSelected_Socket->can_read(20)) #Wait for 20 seconds
{
sysread($sNew_Socket,$sBuffer,1<<10);
$sData_Recevied.=$sBuffer;
if($sBuffer =~/\/message_end>/)
{
last;
}
}
$sNew_Socket->send($sData_Recevied);
close($sNew_Socket);
exit;
}
------------------------------------------------------------------------------------
Also,when i run the following command
ps -A|grep perl
3466 pts/1 00:00:00 perl
3469 pts/1 00:00:00 perl <defunct>
3473 pts/1 00:00:00 perl <defunct>
3478 pts/1 00:00:00 perl <defunct>
3482 pts/1 00:00:00 perl <defunct>
3486 pts/1 00:00:00 perl <defunct>
3490 pts/1 00:00:00 perl <defunct>
please known me if i am missing something.
With Regards
Vikrant
I have written a code for Listening socket(Server) that serve multiple
clients request.The Socket(Server) accept the data from clients and send
back them the same data for validation.
But,I am facing a problem while running the following code .The code
creating a Zombie for each client request.
-----------------------------------------------------------------
#!/usr/bin/perl
use IO::Select;
use IO::Socket::INET;
#LISTENING SOCKET
$sListening_Socket = new IO::Socket::INET (LocalPort => 36545,
Proto => "tcp",
Listen => 4,
Type => SOCK_STREAM)
or die "Could not create socket";
REQUEST:
while ($sNew_Socket = $sListening_Socket->accept())
{
if($iChild_Pid=fork) #Check the Child Process ID
{
close ($sNew_Socket); #Parent closes unused handle
next REQUEST;
} defined($iChild_Pid) or die "Cannot fork";
close ($sListening_Socket); #Child closes unused Handle
$obSelected_Socket = IO::Select->new($sNew_Socket);
while( $obSelected_Socket->can_read(20)) #Wait for 20 seconds
{
sysread($sNew_Socket,$sBuffer,1<<10);
$sData_Recevied.=$sBuffer;
if($sBuffer =~/\/message_end>/)
{
last;
}
}
$sNew_Socket->send($sData_Recevied);
close($sNew_Socket);
exit;
}
------------------------------------------------------------------------------------
Also,when i run the following command
ps -A|grep perl
3466 pts/1 00:00:00 perl
3469 pts/1 00:00:00 perl <defunct>
3473 pts/1 00:00:00 perl <defunct>
3478 pts/1 00:00:00 perl <defunct>
3482 pts/1 00:00:00 perl <defunct>
3486 pts/1 00:00:00 perl <defunct>
3490 pts/1 00:00:00 perl <defunct>
please known me if i am missing something.
With Regards
Vikrant