Jump to content
  • Advertisement
Sign in to follow this  
RuneSword2

read udp header with winsock

This topic is 4866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Setting the IP_HDRINCL option to TRUE causes the send function to include the IP header ahead of the data it's sending and causes the receive function to include the IP header as part of the data. Thus, when you call a Winsock send function, you must include the entire IP header ahead of the data and fill each field of the IP header correctly. This option is available only on Windows 2000+.

Share this post


Link to post
Share on other sites
what i reaaly want is to get the size of the udp from the header, and then read the data of the datagram when i have the size, It's possible?

I've read about raw sockets but I don't find any sample or well documented tutorial about.

Share this post


Link to post
Share on other sites
This is unnecessary. All UDP datagrams arrive fully or do not arrive at all. You will never receive more than one datagram from a single call to recvfrom() -- UDP is not a streaming protocol that requires you determine the length before reading.

recvfrom() returns the number of bytes in the datagram. If the sender sent 0 bytes in the datagram message, the recvfrom() function returns 0 bytes. If 100 senders send 100 40-byte datagrams, you will have to call recvfrom() 100 times and each time the recvfrom() function will return 40 bytes.

The IP header's packet size field will ALWAYS EQUAL (minus the size of the UDP packet header) the value returned by recvfrom(). It is therefore redundant and a lot more work to try and snag it.

Robert

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!