python black hats udp client

The TCP client will be able to get a simple modification of the above UDP client

Import Socket 
target_host = " 127.0.0.1 " 
target_port = 80 
Client = socket.socket (socket.AF_INET, socket.SOCK_DGRAM) # socket type to the client udp SOCK_DGRAM Representative 
A = ' unjiijio ' 
client.sendto (A. encode (), (target_host, target_port)) # call the sendto () function transmits data 
data, addr = client.recvfrom (4096) # use revefrom () function receives data packets 
Print (data)

Because udp is a stateless protocol, so no need to call connect () function

Guess you like

Origin www.cnblogs.com/lzlzzzzzz/p/12557046.html