title: How do scripting languages use sockets?
body: <p>Python, Perl and PHP, all support <a href="http://en.wikipedia.org/wiki/Stream_socket" rel="nofollow noreferrer">TCP stream sockets</a>. But exactly how do I use sockets in a script file that is run by a webserver (eg Apache), assuming I only have FTP access and not root access to the machine?</p>
  
  <ol>
  <li><p>When a client connects to a specific port, how does the script file get invoked?</p></li>
  <li><p>Does the script stay "running" for the duration of the connection? (could be hours)</p></li>
  <li><p>So will multiple "instances" of the script be running simultaneously?</p></li>
  <li><p>Then how can method calls be made from one instance of the script to another?</p></li>
  </ol>