<HTML><FONT FACE=arial,helvetica><BLOCKQUOTE CITE STYLE="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px" TYPE="CITE"><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF">Can this be done by having MC running in the background *prior* to the<BR>
cgi being called by the server - not sure how the os associated the<BR>
script with the engine.... or whether it creates another process....<BR>
would like to though:)</FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF"><BR>
</BLOCKQUOTE></FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF"><BR>
Unfortunately, no- the server will spawn a new cgi process for each request.<BR>
I have found a couple options, however:<BR>
<BR>
1). Run a simple server which takes request from cgi scripts (over sockets), and supplies the persistent data.<BR>
<BR>
2) Run a pool of servers, all listening on their own port, and then still utilize 1).<BR>
<BR>
I did cook up something fun to play with. I stuck this in a script "httpd" and call "./httpd 8080 10" from the terminal. What I get: 10 processes listening on ports 8080-8089.<BR>
<BR>
This is somewhat like apache's behavior: a bunch of child processes handle requests. Problem is, Apache uses fork() and select(), so it manages to get all of the processes listening on the *same* port. I can't see how that is possible with Metacard.<BR>
<BR>
</FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF">#!mc<BR>
<BR>
global thisPort, myID, isLastChild<BR>
<BR>
on startup<BR>
put $1 into thisPort<BR>
put $2 into numChildren<BR>
put $3 into myID<BR>
put $4 into isLastChild<BR>
<BR>
if (myID is empty) then put 0 into myID<BR>
<BR>
accept connections on port thisPort with message "newConnect"<BR>
<BR>
repeat with pID=1 to numChildren-1<BR>
open process ($0&&($1+pID)&&"0"&&(pID)&&(pID = (numChildren - 1)))<BR>
end repeat<BR>
<BR>
end startup<BR>
<BR>
on newConnect s<BR>
read from socket s until empty<BR>
put "HTTP/1.0 200 OK WebCF"&crLF into r<BR>
put "Content-Type: text/plain"&crLF after r<BR>
put "Content-Length: "&length(myID)&crLF&crLF after r<BR>
put myID after r<BR>
write r to socket s<BR>
end newConnect</FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF"></FONT></HTML>