<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>
&nbsp;  put $1 into thisPort<BR>
&nbsp;  put $2 into numChildren<BR>
&nbsp;  put $3 into myID<BR>
&nbsp;  put $4 into isLastChild<BR>
<BR>
&nbsp;  if (myID is empty) then put 0 into myID<BR>
<BR>
&nbsp;  accept connections on port thisPort with message "newConnect"<BR>
<BR>
&nbsp;  repeat with pID=1 to numChildren-1<BR>
&nbsp;&nbsp;&nbsp;  open process ($0&amp;&amp;($1+pID)&amp;&amp;"0"&amp;&amp;(pID)&amp;&amp;(pID = (numChildren - 1)))<BR>
&nbsp;  end repeat<BR>
<BR>
end startup<BR>
<BR>
on newConnect s<BR>
&nbsp;&nbsp;  read from socket s until empty<BR>
&nbsp;&nbsp;  put "HTTP/1.0 200 OK WebCF"&amp;crLF into r<BR>
&nbsp;&nbsp;  put "Content-Type: text/plain"&amp;crLF after r<BR>
&nbsp;&nbsp;  put "Content-Length: "&amp;length(myID)&amp;crLF&amp;crLF after r<BR>
&nbsp;&nbsp;  put myID after r<BR>
&nbsp;&nbsp;  write r to socket s<BR>
end newConnect</FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF"></FONT></HTML>