UDP or user datagram protocol is an alternative protocol to its more common counterpart TCP. UDP like TCP is a protocol for packet transfer from 1 host to another, but has some important differences. UDP is a connectionless and non-stream oriented protocol. It means a UDP server just catches incoming packets from any and many hosts without establishing a reliable pipe kind of connection.
In this article we are going to see how to use UDP sockets in python.
Create udp sockets
A udp socket is created like this
CODE:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)The SOCK_DGRAM specifies datagram (udp) sockets.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-747039/
,如需转载,请注明出处,否则将追究法律责任。