here client that sends messages to the previous serverudp message client import socket socket socket(socket af_inetsocket sock_dgrams sendto( "hello world"("" )respaddr recvfrom( print(resps sendto( "spam"("" )respaddr recvfrom( print(resps close(notes not all constants and socket options are available on all platforms if portability is your goalyou should only rely upon options that are documented in major sources such as the richard stevens unix network programming book cited at the beginning of this section notable omissions from the socket module are recvmsg(and sendmsg(system callscommonly used to work with ancillary data and advanced network options related to packet headersroutingand other details for this functionalityyou must install third-party module such as pyxapi ( there is subtle difference between nonblocking socket operations and operations involving timeout when socket function is used in nonblocking modeit will return immediately with an error if the operation would have blocked when timeout is seta function returns an error only if the operation doesn' complete within specified timeout ssl the ssl module is used to wrap socket objects with the secure sockets layer (ssl)which provides data encryption and peer authentication python uses the openssl library (sojust the essential elements of using this module are covered here with the assumption that you know what you're doing when it comes to ssl configurationkeyscertificatesand other related matterswrap_socket(sock [**opts]wraps an existing socket sock (created by the socket modulewith ssl support and returns an instance of sslsocket this function should be used before subsequent connect(or accept(operations are made opts represents number of keyword arguments that are used to specify additional configuration data lib fl ff