Why the ip adress isn't changing while program is running?

Hello, I use next code on my RCM 6710:

int Init()
{
if (ifconfig(IF_ETH0, IFS_IPADDR, aton(“10.10.6.100”),
IFS_NETMASK, aton(“255.255.255.0”), IFS_ROUTER_SET, aton(“10.10.6.1”),
IFS_UP, IFS_END)==0)
{
sock_init_or_exit(1);
return 1;
}
else
return 0;
}

This code doesn’t work, because sock_init_or_exit(1) says that ip is the one I set by #define _PRIMARY_STATIC_IP

If you set a primary static IP address the way you have done then it is not possible to change the address at run time.

If you want to have full flexibility on setting IP configurations at run time you are probably best setting TCPCONFIG to 6 and issuing the required ifconfig()s to set up the addressing you need. The addp.c example in the samples cpip folder is a good one to examin to see how this works.

Regards,
Peter

1 Like

Worked great for me, thank you.