Jeremy Howard <[EMAIL PROTECTED]> wrote: > Is there _any_ solution to sharing sockets? My WebMail server > keeps a pool of IMAP connections open (one per user) but it > currently needs to create a connection for every user for every > process that they use. This is awfully inefficient. I'm planning > on creating a little Unix Socket daemon that keeps a single pool > of connections, and make all IMAP connections go through the > daemon. This seems like it should be unnecessary though--isn't > there some way of sharing sockets amongst processes? Sharing them automatically is not standard; you'd need to use clone(...CLONE_FILES...) under Linux or rfork() under FreeBSD instead of fork(), and that would share all the file descriptors, including the sockets. The different processes would still need to keep track of allocation and who is using which fd, but you can do that over shared memory. It should be possible to do that to Apache just by changing the place where it forks off its child processes. Sharing sockets one by one is relatively easier; a process can pass an open fd to another through a Unix-domain socket (that's what lingerd, my Apache scalability fix for non-keepalive servers, does). The original process with the fd can then close it, or keep it around for later if connections are reusable. You'd need to write a daemon to hand out the fd's though; for the send_fd() and recv_fd() functions, you could take code or inspiration from lingerd (the code is at ftp://iagora.com/pub/software/lingerd/lingerd-0.91b.tar.gz ) -- Roger Espel Llima, [EMAIL PROTECTED] http://www.iagora.com/~espel/index.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]