Python實現UDP包程式設計

jieforest發表於2012-10-23
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部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-747039/,如需轉載,請註明出處,否則將追究法律責任。

相關文章