rahardj@ccu.umanitoba.ca (Budi Rahardjo) (05/12/91)
1. How do I make an array of filehandle ?
I am trying to accept several socket connections, something like ...
accept(NS[$i],S);
2. I am trying to write a server which will handle a max of
5 connections at one time.
Would the following algorithm make sense ?
START:
- init a blocking socket, and wait until there is a connection
- there is a connection, accept it as NS[$i] ($i=0)
- change the generic socket S into non-blocking
PROCESS:
- process one line (request) from NS[$i] if (NS[$i] is not empty)
- incr. $i, if $i > 5 then set $i=0
- if NS[$i] is not empty then goto PROCESS
# NS[$i] empty
- check if there is a request/connection (check error when doing accept())
- there is a connection, accept it as NS[$i] and goto PROCESS
- there is no connection, count the number of empty connections ($empty)
- if no more connection ($empty = 5) then goto START
thanks,
-- budi