谷老师: 你好! 用MFC写的一个程序,在程序里面调用UDT,当UDT::connect() 失败以后,句柄数和线程数都没有释放,连接一次句柄数都会增加30几个而线程数都会增加2个。请问有什么解决办法? (注:所用版本为 UDT: UDP-based Data Transfer Library - version 4)
代码示例:
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; }
是不是死锁在UDT::close(Udt_Sock);这里
<BODY>
我最喜欢淘东西了,最近运气好,前几天看到这个活动,拍了两双,没想到发过来去专柜检验确实是正品~赚了~还有情侣款!http://dfhtdh.gxsl.net
This is an automatic reply, confirming that your e-mail was received.Thank you
Log in to post a comment.
谷老师:
你好!
用MFC写的一个程序,在程序里面调用UDT,当UDT::connect() 失败以后,句柄数和线程数都没有释放,连接一次句柄数都会增加30几个而线程数都会增加2个。请问有什么解决办法? (注:所用版本为 UDT: UDP-based Data Transfer Library - version 4)
代码示例:
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
是不是死锁在UDT::close(Udt_Sock);这里
<BODY>
</body>
</html>
<BODY>
</body>
</html>
<BODY>
</body>
</html>