public void open(IPEndPoint addr)
{
// construct an socket
m_iSocket = new Socket(m_iIPversion, SocketType.Dgram, ProtocolType.IP);
if (null != addr)
{
m_iSocket.Bind(addr);
//socklen_t namelen = (AddressFamily.InterNetwork == m_iIPversion) ? sizeof(sockaddr_in) : sizeof(sockaddr_in6);
//if (0 != bind(m_iSocket, addr, namelen))
// throw new CUDTException(1, 3, NET_ERROR);
}
else
{
//sendto or WSASendTo will also automatically bind the socket
// addrinfo hints;
// addrinfo* res;
// memset(&hints, 0, sizeof(struct addrinfo));
// hints.ai_flags = AI_PASSIVE;
// hints.ai_family = m_iIPversion;
// hints.ai_socktype = Winsock.SOCK_DGRAM;
// if (0 != getaddrinfo(null, "0", &hints, &res))
// throw new CUDTException(1, 3, NET_ERROR);
// if (0 != bind(m_iSocket, res.ai_addr, res.ai_addrlen))
// throw new CUDTException(1, 3, NET_ERROR);
// freeaddrinfo(res);
}
setUDPSockOpt();
}