Networking Forums

Networking Forums > Computer Networking > Linux Networking > Udp programming question

Reply
Thread Tools Display Modes

Udp programming question

 
 
RedCrow
Guest
Posts: n/a

 
      04-16-2004, 05:43 PM
Hi,
I have a machine that reads periodically a message on a socket.
If there've been more than one send on that address, I'd like to read
only the last arrived packet, and not the older one and so on.
How can I do to make the receive of a new packet overwrite the old
one in the kernel buffer? In the buffer should be only the last arrivad
message..

Thanks in advance
RedCrow
 
Reply With Quote
 
 
 
 
Jeff Breitner
Guest
Posts: n/a

 
      04-16-2004, 11:06 PM
RedCrow wrote:
> Hi,
> I have a machine that reads periodically a message on a socket.
> If there've been more than one send on that address, I'd like to read
> only the last arrived packet, and not the older one and so on.
> How can I do to make the receive of a new packet overwrite the old
> one in the kernel buffer? In the buffer should be only the last arrivad
> message..
>
> Thanks in advance
> RedCrow



UDP packets can arrive out of order, so the "last packet sent" could
certainly be the first packet that was actually sent. If you want to
make sure they are ordered, then don't use UDP or plug some sort of
timestamp or serial number into your data that can be used by your
server/client to keep track of it.

The kernel is simply going to throw the data your way; which is exactly
what you want it to do.


--

WWJD? JWRTFM
Rot13 for email address: yvfgf @ ehqa.pbz
 
Reply With Quote
 
RedCrow
Guest
Posts: n/a

 
      04-17-2004, 05:41 AM

> UDP packets can arrive out of order, so the "last packet sent" could
> certainly be the first packet that was actually sent. If you want to
> make sure they are ordered, then don't use UDP or plug some sort of
> timestamp or serial number into your data that can be used by your
> server/client to keep track of it.
>


It is exactly what I've done. I made a timestamp to see if i read an out
of order packet.
But happens this thing: if a send is delayed beyond the period, the
receive fails, and my buffer contains the old packet. It assumes that the
packet didn't arrive. When, in the next period, I go to read the packet,
I'd like to read the one relative to that period, not the older one. One
delay in the send makes the queue of messages shifted by one, so in every
period i read the message of the previous period. I thought that this was
avoidable simply making the kernel buffer contain only one packet, and
making a new arrive delete the old content of the buffer...

Any suggestions?

 
Reply With Quote
 
Jeff Breitner
Guest
Posts: n/a

 
      04-18-2004, 03:04 AM
RedCrow wrote:

> It is exactly what I've done. I made a timestamp to see if i read an out
> of order packet.
> But happens this thing: if a send is delayed beyond the period, the
> receive fails, and my buffer contains the old packet. It assumes that the
> packet didn't arrive. When, in the next period, I go to read the packet,
> I'd like to read the one relative to that period, not the older one. One
> delay in the send makes the queue of messages shifted by one, so in every
> period i read the message of the previous period. I thought that this was
> avoidable simply making the kernel buffer contain only one packet, and
> making a new arrive delete the old content of the buffer...
>
> Any suggestions?
>



Have you thought about flushing the buffer after you've dealt with the
data? No data, no action required.

--

WWJD? JWRTFM
Rot13 for email address: yvfgf @ ehqa.pbz
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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
A newbie socket programming question dnucit@gmail.com Linux Networking 0 07-11-2006 01:54 PM
General question about use of ports when programming with sockets 0to60 Windows Networking 4 10-10-2005 09:59 AM
help programming NAT Giacomo Linux Networking 3 09-10-2005 12:34 PM
Wireless PEAP/MSCHAPV2 client programming question Jim Howard Wireless Networks 6 07-02-2005 11:53 AM
Network Programming (misc question) xm Linux Networking 1 02-20-2005 07:45 AM



1 2 3 4 5 6 7 8 9 10 11