预期标识符标记'('

时间:2013-11-23 04:03:08

标签: c sockets

我无法将主机名转换为ping版本的traceroute(traceroute -I)的IP地址

我相信我可能会错误地投射我的指针,我正在尝试访问sockaddr_in结构的sin_port和in_addr结构的s_addr。

struct addrinfo * addrptr

...call getaddrinfo an start scanning results

if(addrptr->ai_family == AF_INET
      && addrptr->(struct sockaddr_in *)ai_addr->sin_port == 0 
      && addrptr->(struct in_addr *)ai_addr->s_addr == INADDR_ANY){

错误发生在:

               & addrptr->(struct sockaddr_in *)ai_addr->sin_port == 0 
                          ^

1 个答案:

答案 0 :(得分:1)

((struct sockaddr_in *)(addrptr->ai_addr))->sin_port
((struct sockaddr_in *)(addrptr->ai_addr))->s_addr