and server examples on the same machinelocalhostas shown earlierall you need then is computer that allows socketsand most do secondthe socket module generally raises exceptions if you ask for something invalid for instancetrying to connect to nonexistent server (or unreachable serversif you have no internet linkfailsc:\pp \internet\socketspython echo-client py www nonesuch com hello traceback (most recent call last)file "echo-client py"line in sockobj connect((serverhostserverport)connect to server machine socket error[errno connection attempt failed because the connected party did not properly respond after period of timeor established connection failed because connected host has failed to respond finallyalso be sure to kill the server process before restarting it againor else the port number will still be in useand you'll get another exceptionon my remote server machine]ps - pid tty pts/ pts/ pts/ stat ss rtime command : python echo-server py : -bash : ps - ]python echo-server py traceback (most recent call last)file "echo-server py"line in sockobj bind((myhostmyport)bind it to server port number socket error[errno only one usage of each socket address (protocolnetwork address/portis normally permitted series of ctrl-cs will kill the server on linux (be sure to type fg to bring it to the foreground first if started with an &)]fg python echo-server py traceback (most recent call last)file "echo-server py"line in connectionaddress sockobj accept(wait for next client connect keyboardinterrupt as mentioned earliera ctrl- kill key combination won' kill the server on my windows machinehowever to kill the perpetually running server process running locally on windowsyou may need to start task manager ( using ctrl-alt-delete key combination)and then end the python task by selecting it in the process listbox that appears closing the window in which the server is running will also suffice on windowsbut you'll lose that window' command history you can also usually kill server on linux with kill - pid shell command if it is running in another window or in the backgroundbut ctrl- requires less typing socket programming