gethostbyaddr segmentation error FAQ

来源:互联网 发布:淘宝快递不取 编辑:程序博客网 时间:2024/05/21 22:40

p, li { white-space: pre-wrap; }

struct hostent* hostEnt;

hostEnt=gethostbyaddr(inet_ntoa(ptr->ip_src),sizeof(ptr->ip_src),AF_INET);

if(!hostEnt)

{

tmp=new QStandardItem("No Name");

Row.append(tmp);

}else

{

tmp=new QStandardItem(hostEnt->h_name);

Row.append(tmp);

}

above is right,but before I get to know this issue, I didn't check the hostEnt's value,so when there is no result to return , hostEnt-> operation will throw out segmentation error

 

 

note that....

原创粉丝点击