from threading import thread mode int(sys argv[ ]if mode = run server in this process server(elif mode = run client in this process client('client:process=%sos getpid()elserun client threads in process for in range( )thread(target=clientargs=('client:thread=%si,)start(let' run this script on windowstoo (againthis portability is major advantage of socketsfirststart the server in process as an independently launched program in its own windowthis process runs perpetually waiting for clients to request connections (and as for our prior pipe example you may need to use task manager or window close to kill the server process eventually) :\pp \system\processessocket-preview-progs py nowin another windowrun few clients in both processes and threadby launching them as independent programs--using as the command-line argument runs single client processbut spawns five threads to converse with the server on parallelc:\pp \system\processessocket-preview-progs py client got[ "server got[ 'client:process= ']" :\pp \system\processessocket-preview-progs py client got[ "server got[ 'client:process= ']" :\pp \system\processessocket-preview-progs py client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']" :\pp \system\processessocket-preview-progs py client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']"client got[ "server got[ 'client:thread= ']" :\pp \system\processessocket-preview-progs py client got[ "server got[ 'client:process= ']"socket use cases this section' examples illustrate the basic ipc role of socketsbut this only hints at their full utility despite their seemingly limited byte string naturehigher-order use cases for sockets are not difficult to imagine with little extra workfor instanceinterprocess communication