title: Client and PHP backend communication: Sokets, Stream, TCP/UDP?
body: <p><strong>Short version:</strong> I want to connect a Client to a PHP server, but i have a limitation on the server of 10 PHP scripts running  at the same time.  </p>
  
  <p>Question is: <strong>What is the best way to connect a client with PHP script, while staying under the limitation?</strong></p>
  
  <p><strong>Long version:</strong><br>
  My previous questions shows what i am really after, but here it is again:<br>
  I want to develop a a webchat using Java applet as the client side, and PHP as the back end server. Under normal circumstances I wouldn't ask a question like this just use the first thing that google pops up to my search. but right now i'm not under normal circumstances, but under restrictions: Server usage, as in my hosting isa shared account hosting, and 10 Entry processes(aka the number of PHP scripts running at the same time.) I need to make a server to my chat with these in minds, and lowering the performance as much as i can. </p>
  
  <p>I did develop a Client/server connection using TCP in Delphi, but that was long ago, and i forgot much of it. And Now i try to resurface it, i realize i didn't know much about it.</p>
  
  <p>So I got several questions, based on my researches:  </p>
  
  <p><strong>What is a socket?</strong><br>
  I did goggle this but i didn't find a really clear answer to this. This is the standard way of two programs communicating with each other right? and this where maybe one of my wrong knowledge is...</p>
  
  <p><strong>Is TCP/UDP protocol by Sockets?</strong><br>
  I dont even know how to explain this question of mine...</p>
  
  <p><strong>What is stream exactly?</strong><br>
  What i know from my C++ knowledge is its the ability to open files in binary form, and read from it from any point. I might be wrong because my C++ knowledge is old too.</p>
  
  <p>Also i read about PHP sockets, and i found about that its capable to listen to a port with <a href="http://www.php.net/manual/en/function.socket-create-listen.php" rel="nofollow">socket_create_listen</a> but <strong>my concern is that does this scrip runs actively? like an infinitive loop? I'm asking this because the 10 process limitation.</strong><br>
  And if i initiate a TCP Connection with a client does the script runs in an infinite loop again? <strong>does it counts on the active processes?</strong>  </p>
  
  <p>I know UDP doesn't need an active connection, because it just send it en masse and forgets about it terminating the script when it ends, but i don't know about TCP.</p>
  
  <p>Sorry for the long post, and the many questions, and thank you for any help you can offer.</p>
  
  <p><strong>EDIT:</strong> I Forgot about GET/POST methods!
  As i said that I'm planing a webchat and they need to communicate, but aside from direct connection there is the GET/POST method as well, which  the script quickly does and terminates the script, but again the 10 process limit, <strong>what happens when 11 process tries to run at the same time?</strong></p>
  
  <p><strong>Also is there a way to limit the simultaneously running processes? or put into a queue and wait till the others finish?</strong></p>