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



Yes, you were right it was already there (sorry, my mistake), the
bigger problem is how do I send an ack packet????????

Joe Knapka wrote:
myersoft@xxxxxxxxx wrote:

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)

Um... There's the sender's address, right there,
per the documentation for recvfrom(), which you
seem to have read, since you know recvfrom()
returns a 2-item sequence.

No doubt you realized that seconds after hitting
"send".

-- JK

.



Relevant Pages

  • Re: call is blocked in recvfrom() and no further proceedings in Wi
    ... I have tested it on real device. ... call is blocked in recvfrom() and no further proceedings). ... >> My program has to send request to service through port 5070(in this port ... Received the response in Windows(means, for reception I created socket ...
    (microsoft.public.windowsce.embedded)
  • Re: Other source port issues (was Re: UDP bind + sendto fails to set s
    ... > You can use setsockopt, with the SO_REUSEADDR option on the socket, and that should allow you to bind using the same port. ... recvfrom is only called on one socket. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Other source port issues (was Re: UDP bind + sendto fails to s
    ... Create and bind the socket before creating both threads; you should then be able to pass the socket handle to both threads. ... WSAEWOULDBLOCK, meaning there's no data available, and WSAECONNRESET, which in UDP terms means that your last sendto operation on this port failed - it's UDP, how can we know that? ... > recvfrom is only called on one socket. ...
    (microsoft.public.win32.programmer.networks)
  • RE: Other source port issues (was Re: UDP bind + sendto fails to set s
    ... You can use setsockopt, with the SO_REUSEADDR option on the socket, and that should allow you to bind using the same port. ... BOOL bReuse = TRUE; ... there's no guarantee under those circumstances as to which instance of the socket would get a message if both issued a recvfrom call. ...
    (microsoft.public.win32.programmer.networks)
  • Re: [6.x] problem with AIO, non-blocking sockets on freebSD and IE7 on windows.
    ... Yes, Blame Microsoft, but we are breaking the TCP spec, not them. ... A TCP socket isn't the same thing as a named pape or FIFO. ... Using non-blocking I/O does not mean one can suddenly shortcut the FINWAIT-1 and FINWAIT-2 states before going into TIME_WAIT, nor the 2 * MSL timeout before the TCP control block is allowed to go away. ... Otherwise, you might end up sending a RST to a dup'ed packet like a stray ACK, which seems to be almost exactly the problem at hand. ...
    (freebsd-net)