connection send(reply encode()connection close(os _exit( def dispatcher()listen until process killed while truewait for next connectionconnectionaddress sockobj accept(pass to process for service print('server connected by'addressend='print('at'now()reapchildren(clean up exited children now childpid os fork(copy this process if childpid = if in child processhandle handleclient(connectionelseelsego accept next connect activechildren append(childpidadd to active child pid list dispatcher(running the forking server parts of this script are bit trickyand most of its library calls work only on unix-like platforms cruciallyit runs on cygwin python on windowsbut not standard windows python before we get into too many forking detailsthoughlet' focus on how this server arranges to handle multiple client requests firstnotice that to simulate long-running operation ( database updatesother network traffic)this server adds five-second time sleep delay in its client handler functionhandleclient after the delaythe original echo reply action is performed that means that when we run server and clients this timeclients won' receive the echo reply until five seconds after they've sent their requests to the server to help keep track of requests and repliesthe server prints its system time each time client connect request is receivedand adds its system time to the reply clients print the reply time sent back from the servernot their own--clocks on the server and client may differ radicallyso to compare apples to applesall times are server times because of the simulated delayswe also must usually start each client in its own console window on windows (clients will hang in blocked state while waiting for their replybut the grander story here is that this script runs one main parent process on the server machinewhich does nothing but watch for connections (in dispatcher)plus one child process per active client connectionrunning in parallel with both the main parent process and the other client processes (in handleclientin principlethe server can handle any number of clients without bogging down to testlet' first start the server remotely in ssh or telnet windowand start three clients locally in three distinct console windows as we'll see in momentthis server can also be run under cygwin locally if you have cygwin but don' have remote server account like the one on learning-python com used here network scripting