<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sending and Receiving Packets</title>
	<atom:link href="http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/feed/" rel="self" type="application/rss+xml" />
	<link>http://gafferongames.com</link>
	<description>Glenn Fiedler&#039;s Game Development Articles and Tutorials</description>
	<lastBuildDate>Tue, 07 Sep 2010 17:03:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Acetate</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-887</link>
		<dc:creator>Acetate</dc:creator>
		<pubDate>Thu, 06 May 2010 14:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-887</guid>
		<description>@Daniel: If you use unsigned chars, shouldn&#039;t you also make sure that they aren&#039;t zeroed out by the shifts occurring just before this assignment (I don&#039;t know if there is any implicit cast): unsigned int destination_address = ( a &lt;&lt; 24 ) &#124; ( b &lt;&lt; 16 ) &#124; ( c &lt;&lt; 8 ) &#124; d; ?

@Glenn: I have been reading your articles (both physics and networking series) on my spare time for a few days now and I learnt A LOT. Those are clear, succinct and overall well written explanations about often overlooked areas of game development. I think I&#039;ve just made the jump from bad to mediocre game programmer thanks to you. :)</description>
		<content:encoded><![CDATA[<p>@Daniel: If you use unsigned chars, shouldn&#8217;t you also make sure that they aren&#8217;t zeroed out by the shifts occurring just before this assignment (I don&#8217;t know if there is any implicit cast): unsigned int destination_address = ( a &lt;&lt; 24 ) | ( b &lt;&lt; 16 ) | ( c &lt;&lt; 8 ) | d; ?</p>
<p>@Glenn: I have been reading your articles (both physics and networking series) on my spare time for a few days now and I learnt A LOT. Those are clear, succinct and overall well written explanations about often overlooked areas of game development. I think I&#039;ve just made the jump from bad to mediocre game programmer thanks to you. <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-886</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 30 Mar 2010 22:14:52 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-886</guid>
		<description>Hi,
Great series of tutorials, would it be OK to instead of having a non-blocking socket and waste cpu cycles, could I keep the socket blocking and make it load up data into a buffer which another thread processes?

Also,
    unsigned int a = 207;
    unsigned int b = 45;
    unsigned int c = 186;
    unsigned int d = 98;
 - Shouldn&#039;t those be unsigned chars?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great series of tutorials, would it be OK to instead of having a non-blocking socket and waste cpu cycles, could I keep the socket blocking and make it load up data into a buffer which another thread processes?</p>
<p>Also,<br />
    unsigned int a = 207;<br />
    unsigned int b = 45;<br />
    unsigned int c = 186;<br />
    unsigned int d = 98;<br />
 &#8211; Shouldn&#8217;t those be unsigned chars?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-885</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Wed, 03 Feb 2010 16:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-885</guid>
		<description>Select is designed for use with TCP so you get notified when one of your (multiple) TCP sockets has data ready to read -- there is no reason to use select here, because you only need one UDP socket to service any number of virtual connections. Use non-blocking sockets instead.</description>
		<content:encoded><![CDATA[<p>Select is designed for use with TCP so you get notified when one of your (multiple) TCP sockets has data ready to read &#8212; there is no reason to use select here, because you only need one UDP socket to service any number of virtual connections. Use non-blocking sockets instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geo</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-884</link>
		<dc:creator>Geo</dc:creator>
		<pubDate>Wed, 03 Feb 2010 16:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-884</guid>
		<description>Hello,

when implementing UDP on the primary thread you need non-blocking sockets. That&#039;s obviuos. What about using select with (0,0) timeout and then recvfrom if select returns ok ? Is it the same with your solution or worse?

thank you!</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>when implementing UDP on the primary thread you need non-blocking sockets. That&#8217;s obviuos. What about using select with (0,0) timeout and then recvfrom if select returns ok ? Is it the same with your solution or worse?</p>
<p>thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Bell</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-883</link>
		<dc:creator>Martin Bell</dc:creator>
		<pubDate>Wed, 16 Dec 2009 21:52:30 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-883</guid>
		<description>Hello.

Many thanks for your article. I&#039;m just starting to learn the basics of network programming so this is very useful, I think I may have spotted a bug however. Should the use of fcntl for setting the non-blocking flag be like this?

int flags = fcntl(handle, F_GETFL, 0);
fcntl(handle, F_SETFL, flags &#124; O_NONBLOCK);

Ie it has only 3 parameters and sets all the flags in one go. The 4th seems to be ignored in your example and I&#039;m guessing all other flags are being reset to zero as a side effect. I&#039;m testing this on a Mac.

Thanks</description>
		<content:encoded><![CDATA[<p>Hello.</p>
<p>Many thanks for your article. I&#8217;m just starting to learn the basics of network programming so this is very useful, I think I may have spotted a bug however. Should the use of fcntl for setting the non-blocking flag be like this?</p>
<p>int flags = fcntl(handle, F_GETFL, 0);<br />
fcntl(handle, F_SETFL, flags | O_NONBLOCK);</p>
<p>Ie it has only 3 parameters and sets all the flags in one go. The 4th seems to be ignored in your example and I&#8217;m guessing all other flags are being reset to zero as a side effect. I&#8217;m testing this on a Mac.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-882</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Fri, 06 Nov 2009 16:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-882</guid>
		<description>What you would typically do is put a sequence number at the top of your packet and increment it each time you send one

Then loop and receive all packets, which will typically be very small -- then you can use the sequence number to discard all but the most recent packet from each source, per-frame if you wish

cheers</description>
		<content:encoded><![CDATA[<p>What you would typically do is put a sequence number at the top of your packet and increment it each time you send one</p>
<p>Then loop and receive all packets, which will typically be very small &#8212; then you can use the sequence number to discard all but the most recent packet from each source, per-frame if you wish</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Moran</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-881</link>
		<dc:creator>David Moran</dc:creator>
		<pubDate>Fri, 06 Nov 2009 08:36:28 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-881</guid>
		<description>Hello Glenn
Thank you very much for your article, it is the best I have found in internet.
I have one question... what if you want to get only the LAST packet?. I think it has a &quot;time cost&quot; to make a while() and it will be best to get only the last packet (the one you want normally for UDP (real/time) communications; it does not matter was happens before¡)
Is it any way to read directly the last packet?
Thank you very much</description>
		<content:encoded><![CDATA[<p>Hello Glenn<br />
Thank you very much for your article, it is the best I have found in internet.<br />
I have one question&#8230; what if you want to get only the LAST packet?. I think it has a &#8220;time cost&#8221; to make a while() and it will be best to get only the last packet (the one you want normally for UDP (real/time) communications; it does not matter was happens before¡)<br />
Is it any way to read directly the last packet?<br />
Thank you very much</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-880</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Mon, 07 Sep 2009 17:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-880</guid>
		<description>you&#039;re totally correct - in my production code i have an error reporter for all socket operations that logs the error code when they happen, and i have special case handling for handling for EAGAIN

cheers mate</description>
		<content:encoded><![CDATA[<p>you&#8217;re totally correct &#8211; in my production code i have an error reporter for all socket operations that logs the error code when they happen, and i have special case handling for handling for EAGAIN</p>
<p>cheers mate</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thec</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-879</link>
		<dc:creator>thec</dc:creator>
		<pubDate>Mon, 07 Sep 2009 13:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-879</guid>
		<description>right... I see how you work around the problem, but it&#039;s not very wise to skip all error messages like disconnect etc...</description>
		<content:encoded><![CDATA[<p>right&#8230; I see how you work around the problem, but it&#8217;s not very wise to skip all error messages like disconnect etc&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/networking-for-game-programmers/sending-and-receiving-packets/#comment-878</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Mon, 07 Sep 2009 00:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://gafferongames.wordpress.com/?page_id=127#comment-878</guid>
		<description>it&#039;s an error message, of sorts - but i don&#039;t treat it like that

the idea is that in your loop you just keep calling recvfrom until it returns &lt;= 0

this way you keep polling until no packets are available... next frame you try again, until &lt;= 0

cheers and see you on #coders!

ps. check http://gafferongames.com/2009/09/04/the-return-of-the-timestep-crusader/ for a good laugh :)</description>
		<content:encoded><![CDATA[<p>it&#8217;s an error message, of sorts &#8211; but i don&#8217;t treat it like that</p>
<p>the idea is that in your loop you just keep calling recvfrom until it returns &lt;= 0</p>
<p>this way you keep polling until no packets are available&#8230; next frame you try again, until &lt;= 0</p>
<p>cheers and see you on #coders!</p>
<p>ps. check <a href="http://gafferongames.com/2009/09/04/the-return-of-the-timestep-crusader/" rel="nofollow">http://gafferongames.com/2009/09/04/the-return-of-the-timestep-crusader/</a> for a good laugh <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
