嵌入式linux系统重新加载DNS配置
2016-06-12 11:14
726 查看
对于通过wifi等移动网络联网的的嵌入式系统而言,当wifi环境发生变化(如连接新的wifi)时,DNS路由器地址很可能会被更新。在这种情况下,应用程序的DNS也要及时更新,不然应用程序的网络可能会不通,当通过http等协议访问服务器的时候,返回“couldn‘t resolve hostname”错误。
此时,通过如下函数可以更新应用程序的DNS配置。
函数说明如下:
此时,通过如下函数可以更新应用程序的DNS配置。
#include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> res_init();
函数说明如下:
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN. res_init() is normally executed by the first call to one of the other functions.
相关文章推荐
- (十三)Linux基础之软件安装―yum、rpm
- 在Linux中增加swap空间
- linux scp远程拷贝文件及文件夹
- Linux SSH远程文件/目录传输命令scp
- linux 内核官方文档
- Centos 6.5下KVM环境快速搭建
- (十一)Linux基础之日志
- 解决Linux下使用sqlplus不能使用上下键,退格键
- 在CentOS6.8平台使用最新版源代包码编译安装MySQL 5.7.13 推荐
- linux下中断与信号
- Linux环境下的vim编译器的相关配置
- 【Linux】进程调度算法
- (十)Linux基础之传送与压缩
- Linux中java log输出中文乱码
- SecureCRT远程连接Linux下的sqlplus中退格键不能使用之解决方法
- linux 文件删除而空间没有释放的解决办法
- 解决Linux 下sublime text 同一窗口打开多个标签
- (九)Linux基础之ssh
- linux解压多个文件
- Linux中文显示乱码?如何设置centos显示中文