You might find this useful Simple threaded chat server. You could easily add code to check the scalar value of the array holding the active sockets, and refuse connections if over a certain value. But you can also set that limit in the IO::Socket::INET listen option..... so I can't
fully understand your question.You can share them with other applications thru the filenos of the filehandles and pid
of the server script. Look in /proc/$pid/fd for a list of your sockets. As long as you have user rights to those processes, you can read/write to them.
| [reply] |
As has been previously posted, you can indeed create a pool of sockets with some number limit. However, I don't know how this would be useful. The whole point of a socket is that it is either connected to something, or is waiting for connections from something. I suppose you could have a bunch of sockets all connected to the same address/port, and pass them around, but unless your layer7 stuff is stateless, this would be difficult to use. As for 'sharing' sockets between processes, it kind of defeats the purpose. sockets are one of the prime methods of "inter-process communication". In *nix, each socket has an entry in the process file table. You can't move these from process to process. You can keep them via a fork, but then you are back to state issues. Maybe a little more context, and/or a code sample, would help? | [reply] |
Yes you can. Write a function that takes the limit as a parameter and creates an array of hash refs. Each hashref would contain a socket and information whether it is in use or not. Then create functions for getting and freeing a socket from the pool.
For interprocess communication see perlipc.
--
seek $her, $from, $everywhere if exists $true{love};
| [reply] [d/l] |
| [reply] |