A client that will send packets to a server and receive packets from a server. : UDP Client : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » UDP Client »

 

A client that will send packets to a server and receive packets from a server.


import socket

HOST = "127.0.0.1"
PORT = 5000

mySocket = socket.socketsocket.AF_INET, socket.SOCK_DGRAM )

while 1:
   packet = "Packet"
   mySocket.sendtopacket, HOST, PORT ) )
   packet, address = mySocket.recvfrom1024 )
   print "Packet received:"
   print "From host:", address]
   print "Host port:", address]
   print "Length:", lenpacket )
   print "Containing:"
   print "t" + packet + "n"

mySocket.close()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» UDP Client