HELP!!! How do I send an ACK packet in UDP?????

myersoft at gmail.com myersoft at gmail.com
Mon Jul 24 22:23:25 EDT 2006


I need my udp server to send an ACK back to the client when it
successfully receives data from the client to let it know not to retry
the send (yes, I do know this is how TCP works but must be in UDP)
I am using this example code I found on the net for the server, I need
to figure out how to get the ip and port that the client transmitted
from and return an ack response. Any help would be greatly
appreciated..........

from socket import *

# Set the socket parameters
host = "localhost"
port = 21567
buf = 1024
addr = (host,port)

# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)

# Receive messages
while 1:
	data,addr = UDPSock.recvfrom(buf)
	if not data:
		print "Client has exited!"
		break
	else:
		print "\nReceived message '", data,"'"

# Close socket
UDPSock.close()




More information about the Python-list mailing list