<?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: DNS Query Code in C with Linux sockets	</title>
	<atom:link href="https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/</link>
	<description>News, Technology, Entertainment and more</description>
	<lastBuildDate>Mon, 18 May 2020 13:44:52 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: bamless		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-160336</link>

		<dc:creator><![CDATA[bamless]]></dc:creator>
		<pubDate>Sun, 10 Jun 2018 16:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-160336</guid>

					<description><![CDATA[I know that this post is really old but i thought i should comment anyway, to help people who will stumble on this while browsing the web. This code shouldn&#039;t be used in any production code, because it violates c strict aliasing rules (more info: https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule?utm_medium=organic&#038;utm_source=google_rich_qa&#038;utm_campaign=google_rich_qa). When casting the pointer `buf` of unsigned chars to the struct DNS_HEADER (or in any other place that a cast like this happens) we&#039;re invoking undefined behaviour. A better solution would be to use a union to alias the char buffer to a struct DNS_HEADER (this is supported by the c99 and c11 standards), or to use a simple memcpy to copy the contents of the struct into the buffer.]]></description>
			<content:encoded><![CDATA[<p>I know that this post is really old but i thought i should comment anyway, to help people who will stumble on this while browsing the web. This code shouldn&#8217;t be used in any production code, because it violates c strict aliasing rules (more info: <a href="https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule?utm_medium=organic&#038;utm_source=google_rich_qa&#038;utm_campaign=google_rich_qa" rel="nofollow ugc">https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule?utm_medium=organic&#038;utm_source=google_rich_qa&#038;utm_campaign=google_rich_qa</a>). When casting the pointer `buf` of unsigned chars to the struct DNS_HEADER (or in any other place that a cast like this happens) we&#8217;re invoking undefined behaviour. A better solution would be to use a union to alias the char buffer to a struct DNS_HEADER (this is supported by the c99 and c11 standards), or to use a simple memcpy to copy the contents of the struct into the buffer.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Iharob Al Asimi		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-91572</link>

		<dc:creator><![CDATA[Iharob Al Asimi]]></dc:creator>
		<pubDate>Tue, 16 Aug 2016 21:39:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-91572</guid>

					<description><![CDATA[I really appreciate the effort. And it seems that you do understand how to perform a DNS query. But you write terrible c code. I suggest fixing it because it&#039;s really bad.]]></description>
			<content:encoded><![CDATA[<p>I really appreciate the effort. And it seems that you do understand how to perform a DNS query. But you write terrible c code. I suggest fixing it because it&#8217;s really bad.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: AD		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-67582</link>

		<dc:creator><![CDATA[AD]]></dc:creator>
		<pubDate>Wed, 12 Nov 2014 16:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-67582</guid>

					<description><![CDATA[isnt aa part in dns header should be after opcode  ? In your code you are using standard query which is 0 and aa which is again set to 0, that&#039;s why it is working fine i guess. reference : https://www.ietf.org/rfc/rfc1035.txt


Anyways thanks for snippet it is useful :)]]></description>
			<content:encoded><![CDATA[<p>isnt aa part in dns header should be after opcode  ? In your code you are using standard query which is 0 and aa which is again set to 0, that&#8217;s why it is working fine i guess. reference : <a href="https://www.ietf.org/rfc/rfc1035.txt" rel="nofollow ugc">https://www.ietf.org/rfc/rfc1035.txt</a></p>
<p>Anyways thanks for snippet it is useful :)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-67577</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Mon, 10 Nov 2014 11:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-67577</guid>

					<description><![CDATA[Is there some way I can get the TTL value from the answers portion?? I tried the following but it returns 0 (ntohs(answers[i].resource-&#062;ttl) majority of the time.]]></description>
			<content:encoded><![CDATA[<p>Is there some way I can get the TTL value from the answers portion?? I tried the following but it returns 0 (ntohs(answers[i].resource-&gt;ttl) majority of the time.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-65127</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Tue, 21 May 2013 11:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-65127</guid>

					<description><![CDATA[Very nice article! Can you provide more information about what the ReadName functions does? In my opinion it&#039;s the most important function from the entire program and it&#039;s very poor explainded. Thank you!]]></description>
			<content:encoded><![CDATA[<p>Very nice article! Can you provide more information about what the ReadName functions does? In my opinion it&#8217;s the most important function from the entire program and it&#8217;s very poor explainded. Thank you!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: cristian_gog		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33732</link>

		<dc:creator><![CDATA[cristian_gog]]></dc:creator>
		<pubDate>Mon, 14 May 2012 09:06:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-33732</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33681&quot;&gt;Razvan&lt;/a&gt;.

yeah ..  is not implemented, &#038; there are some problems interpreting the message when MX is used ( because of the whitespaces i think )]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33681">Razvan</a>.</p>
<p>yeah ..  is not implemented, &amp; there are some problems interpreting the message when MX is used ( because of the whitespaces i think )</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Razvan		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33681</link>

		<dc:creator><![CDATA[Razvan]]></dc:creator>
		<pubDate>Wed, 09 May 2012 07:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-33681</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33641&quot;&gt;Razvan&lt;/a&gt;.

Couldn&#039;t edit the post and i replied to it.Seems all is working but the PTR. I seem to not receive the information i need when i try to fetch the domain for an ip address , a little help with this ?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33641">Razvan</a>.</p>
<p>Couldn&#8217;t edit the post and i replied to it.Seems all is working but the PTR. I seem to not receive the information i need when i try to fetch the domain for an ip address , a little help with this ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Razvan		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-33641</link>

		<dc:creator><![CDATA[Razvan]]></dc:creator>
		<pubDate>Sat, 05 May 2012 10:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-33641</guid>

					<description><![CDATA[Please ignore my previous comment,i saw that you also posted a linux version.I want to ask you , how do you fetch dns records for , lets say CNAME or PTR ?]]></description>
			<content:encoded><![CDATA[<p>Please ignore my previous comment,i saw that you also posted a linux version.I want to ask you , how do you fetch dns records for , lets say CNAME or PTR ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rajaona		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-32313</link>

		<dc:creator><![CDATA[Rajaona]]></dc:creator>
		<pubDate>Thu, 12 Apr 2012 17:02:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-32313</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-31677&quot;&gt;Tylkas&lt;/a&gt;.

Thanks soo much ...
Easily Understandable Code....
can you also provide the code for gethostbyaddr() function (in same pattern without using netdb.h library)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-31677">Tylkas</a>.</p>
<p>Thanks soo much &#8230;<br />
Easily Understandable Code&#8230;.<br />
can you also provide the code for gethostbyaddr() function (in same pattern without using netdb.h library)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ching		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-31716</link>

		<dc:creator><![CDATA[ching]]></dc:creator>
		<pubDate>Fri, 24 Feb 2012 11:00:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-31716</guid>

					<description><![CDATA[i do not understand this part...
if(*reader&#062;=192)
324	        {
325	            offset = (*reader)*256 + *(reader+1) - 49152; //49152 = 11000000 00000000 ;)
326	            reader = buffer + offset - 1;
327	            jumped = 1; //we have jumped to another location so counting wont go up!
328	        }
329	        else
330	        {
331	            name[p++]=*reader;
332	        }
333	 
334	        reader = reader+1;
335	 
336	        if(jumped==0)
337	        {
338	            *count = *count + 1; //if we havent jumped to another location then we can count up
339	        }
340	    }
341	 
342	    name[p]=&#039;&#039;; //string complete
343	    if(jumped==1)
344	    {
345	        *count = *count + 1; //number of steps we actually moved forward in the packet
346	    }
347	 

rest of program is understood... 
please help]]></description>
			<content:encoded><![CDATA[<p>i do not understand this part&#8230;<br />
if(*reader&gt;=192)<br />
324	        {<br />
325	            offset = (*reader)*256 + *(reader+1) &#8211; 49152; //49152 = 11000000 00000000 ;)<br />
326	            reader = buffer + offset &#8211; 1;<br />
327	            jumped = 1; //we have jumped to another location so counting wont go up!<br />
328	        }<br />
329	        else<br />
330	        {<br />
331	            name[p++]=*reader;<br />
332	        }<br />
333<br />
334	        reader = reader+1;<br />
335<br />
336	        if(jumped==0)<br />
337	        {<br />
338	            *count = *count + 1; //if we havent jumped to another location then we can count up<br />
339	        }<br />
340	    }<br />
341<br />
342	    name[p]=&#8221;; //string complete<br />
343	    if(jumped==1)<br />
344	    {<br />
345	        *count = *count + 1; //number of steps we actually moved forward in the packet<br />
346	    }<br />
347	 </p>
<p>rest of program is understood&#8230;<br />
please help</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tylkas		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-31677</link>

		<dc:creator><![CDATA[Tylkas]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 14:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-31677</guid>

					<description><![CDATA[But I don&#039;t understand this moment:

~$ ./client 
Enter Hostname to Lookup : asdqwe
Resolving asdqwe
...
Answer Records : 1 
Name : asdqwe has IPv4 address : 67.215.65.132

Why 67.215.65.132 ?]]></description>
			<content:encoded><![CDATA[<p>But I don&#8217;t understand this moment:</p>
<p>~$ ./client<br />
Enter Hostname to Lookup : asdqwe<br />
Resolving asdqwe<br />
&#8230;<br />
Answer Records : 1<br />
Name : asdqwe has IPv4 address : 67.215.65.132</p>
<p>Why 67.215.65.132 ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tylkas		</title>
		<link>https://www.binarytides.com/dns-query-code-in-c-with-linux-sockets/comment-page-1/#comment-31676</link>

		<dc:creator><![CDATA[Tylkas]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 13:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=515#comment-31676</guid>

					<description><![CDATA[Nice code, thank you =]]]></description>
			<content:encoded><![CDATA[<p>Nice code, thank you =]</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
