Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!rahardj From: rahardj@ccu.umanitoba.ca (Budi Rahardjo) Newsgroups: comp.lang.perl Subject: How do I make an array of Filehandle ? Keywords: array, filehandle Message-ID: <1991May12.084254.13480@ccu.umanitoba.ca> Date: 12 May 91 08:42:54 GMT Sender: rahardj@ccu.umanitoba.ca (Budi Rahardjo) Followup-To: comp.lang.perl Organization: University of Manitoba, Winnipeg, Canada Lines: 28 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