Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > HELP!!! How do I send an ACK packet in UDP?????

Reply
Thread Tools

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

 
 
myersoft@gmail.com
Guest
Posts: n/a
 
      07-25-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()

 
Reply With Quote
 
 
 
 
Joe Knapka
Guest
Posts: n/a
 
      07-25-2006
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
 
Reply With Quote
 
 
 
 
Joe Knapka
Guest
Posts: n/a
 
      07-25-2006
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
 
Reply With Quote
 
myersoft@gmail.com
Guest
Posts: n/a
 
      07-25-2006
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:
> 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


 
Reply With Quote
 
Joe Knapka
Guest
Posts: n/a
 
      07-25-2006
wrote:

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


Look at the docs for socket.sendto(). Of course, deciding
what data should be in your "ACK" packet is for you to decide.

Cheers,

-- JK
 
Reply With Quote
 
Rob Sinclar
Guest
Posts: n/a
 
      07-26-2006
On Wednesday 26 July 2006 00:48, wrote:
> how do I send an ack packet????????


UDP stands for User Datagram Protocol. Ther'es no ack like in TCP.
Define your own protocol ie when machine1 sends the string "ACK",
machine2 has the acknowledge it wanted.

Regards,
Rob
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
import packet.module without importing packet.__init__ ? Gelonida N Python 4 09-11-2011 02:17 PM
convert the ip packet to and from RS-232 packet Li Han Python 2 02-09-2009 02:43 PM
Security: rec'd packet not an ipsec packet ! mediumkuriboh Cisco 0 02-09-2009 12:14 AM
%PIX-4-402106: Rec'd packet not an IPSEC packet. lfnetworking Cisco 3 08-27-2006 05:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57