Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As a prior answer notes, scripting languages have operate in this regard in exactly the same way as compiled programs. Where they differ (potentially) is in the API that they use. The operating system (Windows or Unix-based) offers an API (e.g., <a href="http://en.wikipedia.org/wiki/Bsd_sockets" rel="nofollow noreferrer">BSD sockets</a>) that compiled programs will call directly (typically). Interpreted languages like PHP or Python may offer a different API such as Python's <a href="http://docs.python.org/library/socket.html" rel="nofollow noreferrer">socket API</a> which may simplify some parts of the underlying API.</p> <p>Given any of these APIs, there are many ways in which the actual handling of an incoming TCP connection can be structured. A great and detailed overview of such approaches is available on the c10k webpage: <a href="http://www.kegel.com/c10k.html" rel="nofollow noreferrer">http://www.kegel.com/c10k.html</a> -- in particular, the section on <a href="http://www.kegel.com/c10k.html#strategies" rel="nofollow noreferrer">IO strategies</a>. In short, the choice of answers to your question is up to the programmer and may affect how the resulting program performs under load.</p> <p>To focus on your specific questions:</p> <ol> <li>Many server programs are started <em>before</em> the connection and are running to listen for incoming connections. A special case is inetd which is a superserver: it listens for connections and then hands off those connections to programs that it starts (specified in a config file).</li> <li>Typically, yes, the script remains running for the duration of the connection. However, depending on the larger system architecture, the script could conceivably pass the connection off to another program for handling and then exit.</li> <li>This is a choice, again as enumerated on the <a href="http://www.kegel.com/c10k.html#strategies" rel="nofollow noreferrer">c10k</a> page.</li> <li>This is another choice; operating systems offer a variety of <a href="http://en.wikipedia.org/wiki/Inter-process_communication" rel="nofollow noreferrer">Interprocess Communication (IPC)</a> mechanisms to programs.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload