fixed ipv6 in -r

This commit is contained in:
wangyu- 2018-07-25 05:10:16 -05:00
parent 4d4a9673e1
commit d4564b6249
2 changed files with 6 additions and 5 deletions

View File

@ -881,7 +881,7 @@ int create_fifo(char * file)
#endif
}
/*
int new_listen_socket(int &fd,u32_t ip,int port)
{
fd =socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@ -939,7 +939,7 @@ int new_connected_socket(int &fd,u32_t ip,int port)
}
return 0;
}
*/
int new_listen_socket2(int &fd,address_t &addr)
{
fd =socket(addr.get_type(), SOCK_DGRAM, IPPROTO_UDP);
@ -960,7 +960,7 @@ int new_listen_socket2(int &fd,address_t &addr)
}
int new_connected_socket2(int &fd,address_t &addr)
{
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
fd = socket(addr.get_type(), SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) {
mylog(log_warn, "[%s]create udp_fd error\n", addr.get_str());
return -1;

View File

@ -233,6 +233,7 @@ struct address_t //TODO scope id
{
memset(&inner,0,sizeof(inner));
}
/*
int from_ip_port(u32_t ip, int port)
{
clear();
@ -240,7 +241,7 @@ struct address_t //TODO scope id
inner.ipv4.sin_port=htons(port);
inner.ipv4.sin_addr.s_addr=ip;
return 0;
}
}*/
int from_ip_port_new(int type, void * ip, int port)
{
@ -253,7 +254,7 @@ struct address_t //TODO scope id
}
else if(type==AF_INET6)
{
inner.ipv6.sin6_family=AF_INET;
inner.ipv6.sin6_family=AF_INET6;
inner.ipv6.sin6_port=htons(port);
inner.ipv6.sin6_addr=*((in6_addr*)ip);
}