$Bill Luebkert <> wrote: > Barry Brevik wrote: > >> I'm developing a special purpose mailer for internal company use. >> The application is being developed, and will run on Windows 2000. It >> is a requirement that there be multiple processes all listening on >> port 25 for inbound connections. >> >> Two weeks ago, my program would fork() every time it received a >> connection. This worked great until I discovered that I can only >> fork() 64 processes, even if those processes terminate, before Perl >> refuses to fork any more processes with $! = "resource temporarily >> unavailable". I'm quite sure the children are being cleaned up >> properly. > > I assume you're running on Win32 ? > >> This week I said "a ha!" I'll just pre-fork 16 children all >> listening on port 25, and each will handle a new connection after it >> finishes with the current one. Unfortunately, only the first process >> (and it is always the first) actually receives connections. If it is >> busy, the other 15 children do nothing. >> >> I have spent a great deal of time on this, both reading docs and >> experimenting. It seems that Satan himself has cursed this project. >> I tried setting up the socket in the parent process like I did when >> I forked for each connection. That did not work; apparently if the >> child is listening, it must also setup the socket. >> >> I also tried running multiple CMD boxes each running a non-forking >> version of the code, but only the first instance will receive and >> process connections. >> >> Is there some fundamental thing I'm missing about listening for >> connections, like only one process can do it? Sorry about the long >> post- I thought more background would be better than less. The >> pertinent parts of the code are below: > > Have you tried doing it in one process without forking ? > > If you have to, you can store the messages in files and start BG > processes (detached processes) to process them from the files. If > the processing is minimal, I'd do it all from the single process. > > PS: I would never use fork on Win32.
I am in general agreement with $Bill, but would like to add a couple of points. I would suggest using IO::Socket::INET and IO::Select rather than the code in the original message. Much easier. Also, on a pedantic note, you cannot have multiple processes listening on a single port. Using SO_REUSEADDR means that multiple processes can bind to the port, but only one at a time can listen. This will no doubt be confused by using fork on Win32, which is emulated in Activestate Perl with threads. HTH -- Brian Raven ================================= Atos Euronext Market Solutions Disclaimer ================================= The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of Atos Euronext Market Solutions. L'information contenue dans cet e-mail est confidentielle et uniquement destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail vous parvient par erreur, nous vous prions de bien vouloir prevenir l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre systeme. Le contenu de ce message electronique ne represente pas necessairement la position ou le point de vue d'Atos Euronext Market Solutions. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
