From msfrank@u.washington.edu Sat Dec 8 00:45:34 2001 Received: from jason02.u.washington.edu (jason02.u.washington.edu [140.142.8.52]) by lists.u.washington.edu (8.11.6+UW01.08/8.11.6+UW01.10) with ESMTP id fB88jUn42332 for ; Sat, 8 Dec 2001 00:45:30 -0800 Received: from dante13.u.washington.edu (dante13.u.washington.edu [140.142.15.23]) by jason02.u.washington.edu (8.11.6+UW01.08/8.11.6+UW01.10) with ESMTP id fB88jTw55060 for ; Sat, 8 Dec 2001 00:45:30 -0800 Received: from localhost (msfrank@localhost) by dante13.u.washington.edu (8.11.6+UW01.08/8.11.6+UW01.10) with ESMTP id fB88jT323944 for ; Sat, 8 Dec 2001 00:45:29 -0800 Date: Sat, 8 Dec 2001 00:45:29 -0800 (PST) From: michael scott frank To: UW Linux Group Subject: Re: Creating a Linux Daemon In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Heres my two cents, take it for what its worth since i don't know your exact situation. I'm assuming that all requests to the server are gonna be local, and the data is easily passed through a socket, so i would use unix domain sockets. domain sockets are fairly straightforward (if you are familiar with sockets or even just normal file i/o with read() and write(), then you'll be at home) and they are pretty fast too (x window system uses domain sockets). domain sockets have the same basic semantics of normal INET sockets, the only real difference is the server creates a file of type socket somewhere in the fs (usually in /tmp), and the client 'opens' this file. This is kind of a poor description, but i hope it helps. As for reading material, already mentioned was advanced programming in the unix environment by WRS, which i heartily recommend too. Unix Network Programming Vol. 1, also by WRS, is another bible. APUE has a brief mention of domain sockets, UNPv1 has a whole chapter devoted to it. hope that all helps. feel free to email me off-list if you wanna talk more about details. good luck, Michael ------------------------- .~. Michael Frank /v\ msfrank@u.washington.edu // \\ ------------------------ /( )\ ^`~'^ On Fri, 7 Dec 2001, John Porter Simons wrote: > Hello Linxuers, > (Sorry if this got posted twice, not sure if I was successfully subscribed > to the list the first time...) > > I've got a question that maybe someone could help me with. Say I've got a > simple C program that takes some data, processes it, and returns a result. > And I want to use this program in a server-side web script, but I don't > want to instantiate the program everytime it's needed, because it > maintains large data structures and it may be executed frequently. What I > want to do is load the program on startup like a daemon, and have it stay > in memory. The processing it does is pretty simple, so I don't think it > needs to fork worker threads, it could have a single process which loops > through any requests. > > But I have no idea how to do this. I wouldn't know whether to use pipes or > FIFOs or signals or what... Does anyone know of a good book or web > resource that provides an example of how to do this? I'm guessing that on > startup, the program would write its process ID to a file somewhere, but I > don't know how, from PHP for example, I could send data to the process at > that ID, and how the program would know where to send the result. > > Any help would be appreciated... > > Thanks, > > John Simons > sport@cs.washington.edu > > > .