timely mannerit won' be able to keep up with all the requestsand some clients will eventually be denied connections in real-world client/server programsit' far more typical to code server so as to avoid blocking new requests while handling current client' request perhaps the easiest way to do so is to service each client' request in parallel--in new processin new threador by manually switching (multiplexingbetween clients in an event loop this isn' socket issue per seand we already learned how to start processes and threads in but since these schemes are so typical of socket server programminglet' explore all three ways to handle client requests in parallel here forking servers the script in example - works like the original echo serverbut instead forks new process to handle each new client connection because the handleclient function runs in new processthe dispatcher function can immediately resume its main loop in order to detect and service new incoming request example - pp \internet\sockets\fork-server py ""server sideopen socket on portlisten for message from clientand send an echo replyforks process to handle each client connectionchild processes share parent' socket descriptorsfork is less portable than threads--not yet on windowsunless cygwin or similar installed""import ostimesys from socket import myhost 'myport get socket constructor and constants server machine'means local host listen on non-reserved port number sockobj socket(af_inetsock_streamsockobj bind((myhostmyport)sockobj listen( make tcp socket object bind it to server port number allow pending connects def now()return time ctime(time time()current time on server activechildren [def reapchildren()while activechildrenpidstat os waitpid( os wnohangif not pidbreak activechildren remove(piddef handleclient(connection)time sleep( while truedata connection recv( if not databreak reap any dead child processes else may fill up system table don' hang if no child exited child processreplyexit simulate blocking activity readwrite client socket till eof when socket closed handling multiple clients