首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于ipv6的有关问题(急)

2012-04-07 
关于ipv6的问题(急)现在如里一个字符串(ipv6的地址),请问如何才能转换成Icmp6SendEcho2中需要的structsock

关于ipv6的问题(急)
现在如里一个字符串(ipv6的地址),请问如何才能转换成Icmp6SendEcho2中需要的struct   sockaddr_in6*   DestinationAddress这个结构~~

大家快帮忙呀!!给我写些代码。


[解决办法]
#include <netdb.h>

int getaddrinfo (const char *hostname, const char *service, const struct addrinfo *hints, struct addrinfo **result) ;



struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* AF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* ptr to canonical name for host */
struct sockaddr *ai_addr; /* ptr to socket address structure */
struct addrinfo *ai_next; /* ptr to next structure in linked list */
};

struct sockaddr_in6 {
uint8_t sin6_len; /* length of this struct (28) */
sa_family_t sin6_family; /* AF_INET6 */
in_port_t sin6_port; /* transport layer port# */
/* network byte ordered */
uint32_t sin6_flowinfo; /* flow information, undefined */
struct in6_addr sin6_addr; /* IPv6 address */
/* network byte ordered */
uint32_t sin6_scope_id; /* set of interfaces for a scope */
};


[解决办法]
你是客户端么?不知道需要连接的服务名或端口号么?

热点排行