Reading UDP datagrams

J

jussi

Hi gurus


So I'm getting wanted and unwanted data to an UDP socket. My problem
is, that some times a string that I'm intrested is spilled in two
pieces.

But I know that valid string starts with x02 and end with x03. So I
would like to have a hint how to do some thing like this:

while {1}
read data from socket until we get x02
append every data to $MY_VALID_DATA until we receive end mark
0x3
now we received x03

PROCESS $MY_VALID_DATA (which is x02???????????????x03
and start listening again.



Any help woulr be highly appreciate
-Jussi
 
N

news reader

Hi jussi,

I don't know your application, but what confuses me slightly:

UDP packets may arrive out of order.

If you want to be sure, that you can order your UDP packets you need
special headers and you had to consider them in your application.
RTP is for example a simple UDP format which allows you to order packets.

If you don't know how to order your packets how do you want to combine a
string split between two packets (if I interpret correctly "spilled in
two pieces")


So either I completely misunderstand your question or you have to
resolve the packet ordering issue first.


bye


N.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top