networking udp is often used to monitor instruments that give continuous readingsand where the odd missed reading is not significantand it is sometimes used for audio or video streaming in cases where the occasional missed frame is acceptable both the ftp and the http protocols are built on top of tcpand client/server applications normally use tcp because they need connection-oriented communication and the reliability that tcp provides in this we will develop client/server programso we use tcp pickles another decision that must be made is whether to send and receive data as lines of text or as blocks of binary dataand if the latterin what form in this we use blocks of binary data where the first four bytes are the length of the following data (encoded as an unsigned integer using the struct module)and where the following data is binary pickle the advantage of this approach is that we can use the same sending and receiving code for any application since we can store almost any arbitrary data in pickle the disadvantage is that both client and server must understand picklesso they must be written in python or must be able to access pythonfor exampleusing jython in java or boost python in +and of coursethe usual security considerations apply to the use of pickles the example we will use is car registration program the server holds details of car registrations (license plateseatsmileageand ownerthe client is used to retrieve car detailsto change car' mileage or owneror to create new car registration any number of clients can be used and they won' block each othereven if two access the server at the same time this is because the server hands off each client' request to separate thread (we will also see that it is just as easy to use separate processes for the sake of the examplewe will run the server and clients on the same machinethis means that we can use "localhostas the ip address (although if the server is on another machine the client can be given its ip address on the command line and this will work as long as there is no firewall in the waywe have also chosen an arbitrary port number of the port number should be greater than and is normally between and although port numbers up to are normally valid the server can accept five kinds of requestsget_car_detailschange_mileagechange_ownernew_registrationand shutdownwith corresponding response for each the response is the requested data or confirmation of the requested actionor an indication of an error creating tcp client ||the client program is car_registration py here is an example of interaction (with the server already runningand with the menu edited slightly to fit on the page)