<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>gethostbyname fails always</title>
<description> Hi.. I&amp;#039;m having some problems with some network code, I was wondering if I missed anything. I copied some network init code from examples and posts on this forum, but I&amp;#039;m not sure if I&amp;#039;m initializing correctly, because net_gethostbyname fails always, even when the lookup string is &quot;192.168.1.1&quot;. Here&amp;#039;s what I have:


RFD_RemoteOps* rfd_tcp_client_create(const char* p_host, int p_port) {

s32 result = net_init();
while ( result == -EAGAIN ) {
printf(&quot;.&quot;);
usleep(100000);
result = net_init();
}
printf(&quot;\n&quot;);
if ( result &amp;lt; 0 ) {
printf(&quot;net_init Failed with code %i.\n&quot;, result );
return NULL;
}

char localip[16];
char gateway[16];
char netmask[16];

s32 ifcfg = if_config ( localip, netmask, gateway, TRUE);
if (ifcfg&amp;gt;=0) {
printf (&quot;network configured, ip: %s, gw: %s, mask %s\n&quot;, localip, gateway, netmask);
} else {
printf(&quot;if_config failed with code %i\n&quot;, ifcfg);
return NULL;
}

struct hostent *he;
printf(&quot;looking up host %s\n&quot;, p_host);
if ( (he=net_gethostbyname(p_host)) == NULL) { // get the host info
printf(&quot;gethostbyname failed!\n&quot;);
return NULL;
}

[...]
}

net_gethostbyname fails always, and when I print the results from if_config, &amp;#039;localip&amp;#039; is fine, but the other two (&amp;#039;gateway&amp;#039; and &amp;#039;netmask&amp;#039;) look like garbage.

am I missing anything? is this stuff documented anywhere?

thanks</description><link>http://forum.wiibrew.org/read.php?11,23056,23056#msg-23056</link><lastBuildDate>Wed, 22 Jul 2026 00:48:55 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23129#msg-23129</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23129#msg-23129</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>punto</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />gethostbyname takes a domain name not an IP, something like "www.yahoo.com"</div></blockquote><br />yeah, that&#039;s the bug actually. gethostbyname is supposed to take ips too (like "192.168.1.1")</div></blockquote><br />I never knew that. I&#039;ve always used a name. Maybe there is a bug in the network code.<br /><br />Here&#039;s a link to the source code for net_gethostbyname. Maybe you can figure it out from there.<br /><br />[<a href="http://devkitpro.svn.sourceforge.net/viewvc/devkitpro/trunk/libogc/libogc/network_wii.c?revision=3634&view=markup" rel="nofollow">devkitpro.svn.sourceforge.net</a>]]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 03:28:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23128#msg-23128</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23128#msg-23128</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />gethostbyname takes a domain name not an IP, something like "www.yahoo.com"</div></blockquote><br />yeah, that&#039;s the bug actually. gethostbyname is supposed to take ips too (like "192.168.1.1")]]></description>
<dc:creator>punto</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 03:20:27 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23127#msg-23127</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23127#msg-23127</link><description><![CDATA[ I think possibly <a href="http://github.com/ibrahima/worldwiideweb/blob/1578675829f3b71f1c1669a094562c1dba09f257/source/main.c" rel="nofollow">my sample</a> might help you. My project is pretty much dead in the water but at least that code should be a good example for how to use some of the libogc network functionality.]]></description>
<dc:creator>iofthestorm</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 03:15:05 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23122#msg-23122</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23122#msg-23122</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />what do you use to initialize the network?</div></blockquote>
Pretty much the same as your code.<br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />I&#039;m printing it, it looks good. I also tried hardcoding the ip on the gethostbyname call, same result.</div></blockquote>
Give me an example of what your passing it. gethostbyname takes a domain name not an IP, something like "www.yahoo.com"]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 02:30:07 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23121#msg-23121</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23121#msg-23121</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />Are you sure the "p_host" contains the correct value.</div></blockquote><br />I&#039;m printing it, it looks good. I also tried hardcoding the ip on the gethostbyname call, same result.<br /><br /><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />I&#039;ve used this function before and it works great. Here&#039;s my code, you can see if it works for you.</div></blockquote><br />what do you use to initialize the network?]]></description>
<dc:creator>punto</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 02:23:55 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23107#msg-23107</guid>
<title>Re: gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23107#msg-23107</link><description><![CDATA[ Are you sure the "p_host" contains the correct value. I&#039;ve used this function before and it works great. Here&#039;s my code, you can see if it works for you.<br /><br /><pre class="bbcode">

	char* getipbyname(char *domain)
	{
		struct hostent *host = 0;

		host = net_gethostbyname(domain);

		if(host == NULL) 
                  return 0;

		struct sockaddr_in tmp;

		memcpy(&tmp.sin_addr,host-&gt;h_addr_list[0],host-&gt;h_length);


		return inet_ntoa(tmp.sin_addr);
	};
</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Jul 2009 00:34:20 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,23056,23056#msg-23056</guid>
<title>gethostbyname fails always</title><link>http://forum.wiibrew.org/read.php?11,23056,23056#msg-23056</link><description><![CDATA[ Hi.. I&#039;m having some problems with some network code, I was wondering if I missed anything. I copied some network init code from examples and posts on this forum, but I&#039;m not sure if I&#039;m initializing correctly, because net_gethostbyname fails always, even when the lookup string is "192.168.1.1". Here&#039;s what I have:<br /><br /><pre class="bbcode">
RFD_RemoteOps* rfd_tcp_client_create(const char* p_host, int p_port) {

	s32 result = net_init();
	while ( result == -EAGAIN ) {
		printf(".");
		usleep(100000);
		result = net_init();
	}
	printf("\n");
	if ( result &lt; 0 ) {
		printf("net_init Failed with code %i.\n", result );
		return NULL;
	}

	char            localip[16];
	char            gateway[16];
	char            netmask[16];

	s32 ifcfg = if_config ( localip, netmask, gateway, TRUE);
	if (ifcfg&gt;=0) {
		printf ("network configured, ip: %s, gw: %s, mask %s\n", localip, gateway, netmask);
	} else {
		printf("if_config failed with code %i\n", ifcfg);
		return NULL;
	}

	struct hostent *he;
	printf("looking up host %s\n", p_host);
	if ( (he=net_gethostbyname(p_host)) == NULL) {  // get the host info
		printf("gethostbyname failed!\n");
		return NULL;
	}

	[...]
}</pre><br />net_gethostbyname fails always, and when I print the results from if_config, &#039;localip&#039; is fine, but the other two (&#039;gateway&#039; and &#039;netmask&#039;) look like garbage.<br /><br />am I missing anything? is this stuff documented anywhere?<br /><br />thanks]]></description>
<dc:creator>punto</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Jun 2009 21:29:13 +0200</pubDate></item>
</channel>
</rss>