On Sat, Apr 23, 2011 at 5:30 PM, Michael Wood <esiot...@gmail.com> wrote: > On 23 April 2011 17:31, Ken Wesson <kwess...@gmail.com> wrote: >> On Sat, Apr 23, 2011 at 5:12 AM, Zlatko Josic <zlatko.jo...@gmail.com> wrote: >>> Hi, >>> I would like to start two progams from Eclipse. One is a server and the >>> other one is a client. >>> I use Load Clojure file in REPL from Eclipse menu. When I start the server >>> it never ends because >>> the server has endless loop where it waits for clients. Now when I start the >>> client programs it never >>> evaluates because REPL is busy with server program. I suppose it works as I >>> described. Maybe I am >>> wrong I am not sure. >>> Any ideas to overcame this situation are welcome. >> >> Have the server spawning function (or both, if the client is GUI) just >> start a separate thread and immediately return. >> >> (In fact, servers normally are multithreaded anyway, aren't they, to >> be able to handle multiple concurrent incoming requests.) > > Well, Java servers probably are yes, but traditional Unix servers > would normally fork a new process for each incoming connection.
Poor man's threads. Although the insulation of each one against crashes in the others might be useful when you're coding in a language with memory management tools as primitive as C's. ;) > There are various ways of doing it. A separate process per client > connection; a separate thread per client connection; a single > process/thread handling multiple clients with select()/poll()/etc. For the first one, the JVM startup time is prohibitive; for the third you need nonblocking socket I/O, which might be in Java 7 or something but isn't available to us JVM-6 users. > starting a pool of processes to avoid the startup time of a new process > when a new client connects. With small lightweight C processes and some suitable system for IPC, this can work. With JVMs, not so much, unless you have RAM coming out of your ears. JVM processes tend to be fairly large; it wouldn't take many 64MB java.exe jobs to start the pagefile thrashing. Even with an 8GB server, you start paging at 128 simultaneous connections in that case, and you certainly can't handle thousands. If you have any kind of complex shared state at all, multiple threads in a single JVM, plus Clojure's STM, will be much nicer. :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en