paul0613 - 2013-05-29

Mr gu:
Use MFC to write a program that calls the UDT in program,
UDT::connect() Failed,Handle number and the number of threads are not released, the handle to add 30 several and will increase the number of threads will increase the number of two. Could you tell me what is the solution? (UDT: UDP-based Data Transfer Library - version 4)

Code sample :

UDTSOCKET Udt_Sock;
struct addrinfo local, peer;
struct addrinfo hints;
struct linger udtlinger;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_DGRAM;
udtlinger.l_onoff = 1;
udtlinger.l_linger = 4;

if (0 != getaddrinfo(NULL, "", &hints, &local))
{
cout << "incorrect network address.\n" << endl;
return 0;
}

Udt_Sock = UDT::socket(local->ai_family, local->ai_socktype, local->ai_protocol);
UDT::setsockopt(Udt_Sock, 0, UDT_LINGER, (char *)&udtlinger, sizeof(udtlinger));

int mss = 1052;
UDT::setsockopt(Udt_Sock, 0, UDT_MSS, &mss, sizeof(int));

freeaddrinfo(local);
char Ip[32] = "192.168.2.212";
char Port[6] = "9300";

if (0 != getaddrinfo(Ip, Port, &hints, &peer))
{
::AfxMessageBox(_T("Incorrect server/peer address."));
return 0;
}
if (UDT::ERROR == UDT::connect(Udt_Sock, peer->ai_addr, peer->ai_addrlen))
{
cout << "Connect Failed.\n" << endl;
UDT::close(Udt_Sock);
return 0;
}

 

Last edit: paul0613 2013-05-30