Setting Host Name

Hi

I was trying to set a host name for my IP address, which mean when i want to access my webrabbit http://90.0.0.110 , i also can access it through http://test

i use the sethostname() but it doesnt work is there any setting that i could have miss out? below are part of my code. Thanks

#define TCPCONFIG 1
#define MY_HOST “test”

void main()
{
sock_init();
tcp_config(“MY_IP_ADDRESS”, “90.0.0.110”);
tcp_config(“MY_NETMASK”, “255.255.255.0”);
tcp_config(“MY_GATEWAY”, “90.0.0.1”);
sethostname(MY_HOST);
}

Hi,

There are a couple of simple ways that might achieve what you need but both rely primarily on external systems to work.

  1. using the macros DHCP_SEND_HOSTNAME and DHCP_CLASS_ID you can get to register your hostname with the DHCP server (although you seem to be using static IP addressing so it would require a bit of juggling to make this work…). According to the comments in BOOTP.LIB some DHCP servers can use this info to respond to DNS queries and provide name resolution. This is obviously very dependent on your DHCP server

  2. Using the local hosts.txt or equivilant file you could set up a static mapping and then the OS will resolve the names for you.

Regards,
Peter