Deda has asked for the wisdom of the Perl Monks concerning the following question:
The problem is threads are somehow interfiering with each other. For e.g. one client wants 'system ("ll")'.. the output is not sent back until another client has connected and sent it's request. Also: when the 'close $clsock;' statment is executed the client is not dissconnected until another client connects or sends a request in HandleClient function. Any ideas why this is happening? It seems to me a thread is somehow paused, until some other thread does something else. I thought threads should run (virtually) paralell.sub ServerRun { my ($server)=@_; my ($client); #wait for client connections while ($client = $server->accept()) { $client->autoflush(1); my $pid = fork; if ($pid == 0) { my $clsock=HandleClient($client); close $clsock; exit 0; } } } sub HandleClient { # this just recieves system commands # to be executed and returns output to client # fn. returns the $client socket }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multi threaded server [fork]
by zby (Vicar) on Aug 06, 2003 at 09:37 UTC | |
by Deda (Novice) on Aug 06, 2003 at 10:24 UTC | |
|
Re: Multi threaded server [fork]
by SyN/AcK (Scribe) on Aug 06, 2003 at 15:06 UTC | |
by Deda (Novice) on Aug 07, 2003 at 08:04 UTC | |
|
Re: Multi threaded server [fork]
by chromatic (Archbishop) on Aug 06, 2003 at 18:01 UTC | |
by Deda (Novice) on Aug 07, 2003 at 08:22 UTC |