This commit is contained in:
wangyu- 2018-07-25 01:52:18 -05:00
parent 184b198470
commit 7ad9a6987c

@ -2464,8 +2464,10 @@ int try_to_list_and_bind(int &fd,u32_t local_ip_uint32,int port) //try to bind
}*/
int try_to_list_and_bind2(int &fd,address_t address) //try to bind to a port,may fail.
{
int old_bind_fd=fd;
if(fd!=-1)
{
close(fd);
}
if(raw_mode==mode_faketcp)
{
fd=socket(address.get_type(),SOCK_STREAM,0);
@ -2474,11 +2476,12 @@ int try_to_list_and_bind2(int &fd,address_t address) //try to bind to a port,ma
{
fd=socket(address.get_type(),SOCK_DGRAM,0);
}
if(old_bind_fd!=-1)
{
close(old_bind_fd);
}
if(fd==-1)
{
mylog(log_debug,"create fd fail\n");
return -1;
}
/*struct sockaddr_in temp_bind_addr={0};
//bzero(&temp_bind_addr, sizeof(temp_bind_addr));