i tried it too but after creating the child process the main process comes
back and start to listne
in line
 $client=$sockHandle->accept()){
then all the child processes blocks
i have atached my code with this
please tel me if there is an error

in line

----- Original Message -----
From: "James Edward Gray II" <[EMAIL PROTECTED]>
To: "Rakhitha Malinda Karunarathne" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, October 16, 2002 11:43 PM
Subject: Re: Help me on concurant comiunication


> Again, this is very complicated, so I can really only give basic
> theory.  The usual strategy of forking servers is to fork just after
> they receive a connection.  The main loop usually looks close to:
>
> while (my $c = $socket->accept) {
> my $child = fork;
> die unless defined $child;
> if ($child == 0) { # in child process
> close $socket; # not needed, but safest
> handle_connection($c);
> exit 0;
> }
> close $c; # in parent process
> }
>
> The other main strategy is preforking, which is better under heavy
> loads.  I believe this is a little closer to what you're describing.
> It typically looks like this:
>
> foreach (1..PREFORK_CHILDREN) {
> next if fork; # parent process
> do_child($socket); # child process
> exit 0; # child never loops
> }
> sub do_child {
> my $socket = shift;
> while (my $c = $socket->accept) {
> handle_connection($c);
> close $c;
> }
> }
>
> Of course, all of this is VERY basic.  There are plenty of gotchas both
> ways.
>
> I'm not sure why your child processes would hang when the parent calls
> accept.  This shouldn't happen.  You mention that you're on Windows,
> but not your version of Perl.  Forking on Windows didn't come until
> version 5.6.0, so you might check that.  Also, try closing the
> listening socket in the children, as I did above, just to be safe.
>
> Again, I highly recommend Network Programming with Perl.  It covers all
> of this very well.  The code above is straight out of it.
>
> Good luck with your server.
>
> James
>
> On Wednesday, October 16, 2002, at 11:27  AM, Rakhitha Malinda
> Karunarathne wrote:
>
> > yes my server forks
> > once the server starts it connects to a socket and starts to listen.
> >   then create processes as much as possible (about 50)
> >
> > but when one process reach the line
> >>>  while($client=$sockHandle->accept()){
> > #lines to handle the client
> > }
> >
> > all the other processes blocks
> >
> > so the problem is when the fist client connected
> > while this process start to handle tat request  one of the other
> > process
> > react to the line
> > $client=$sockHandle->accept()
> > then all the other processes get blocked so the so the process which
> > have a
> > request to handle cant do it
> >
> > I use Windows2000 problem in sort is even when I use fork() when I
> > call the
> > accept() method program stops all the works and waits for a incoming
> > request
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "James Edward Gray II" <[EMAIL PROTECTED]>
> > To: "Rakhitha Malinda Karunarathne" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Tuesday, October 15, 2002 11:29 PM
> > Subject: Re: Help me on concurant comiunication
> >
> >
> >> This is a pretty involved issue, so I would need more information to
> >> help.  By multiple processes, do you mean your server forks?
> >>
> >> As for more information, Network Programming with Perl by Lincoln D.
> >> Stein, covers this issue in detail and is quite good, I think.
> >>
> >> James
> >>
> >> On Tuesday, October 15, 2002, at 12:30  PM, Rakhitha Malinda
> >> Karunarathne wrote:
> >>
> >>> I wrote a program (a server ) to listen for clients requests using
> >>> multiple processes but while a one process waits to incoming client
> >>> requests all the other processes blocks
> >>> how can i over come this problem
> >>> I used IO::Socket::INET for comiunication is there a better way and
> >>> where can i find good documentation to learn about them
> >>> ?
> >>
> >
>

Attachment: server temp.pl
Description: Perl program

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to