in reply to Sockets
Basically let the parent manage the children, let it pass information between the children, and let the children do everything related to communicating with the clients.
The thing is, if you're forking already, do you really need non-blocking sockets? (Note: Your code isn't using non-blocking sockets as it is now.) In any event, when you're doing real-time interaction like this, you want to turn off buffering:
Once you get this working, you might consider trying to re-write it using IO::Select, using non-blocking sockets, via something like this:$|=1; # and perhaps after your accept() call: $new_sock->autoflush;
Getting something fully robust is going to take a lot more coding than you're doing now. You'll learn a lot in the progress, however. Good luck.my $res = $sock->fcntl(F_GETFL, 0); $sock->fcntl(F_SETFL, $res | O_NONBLOCK);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sockets
by meonkeys (Chaplain) on Apr 24, 2001 at 15:03 UTC |