[UDT] about "UDT::select"
Brought to you by:
lilyco
From: XU, L. <xul...@gm...> - 2006-04-07 12:42:29
|
Hello! I've been using UDT on Windows-XP recently. I found it easy to use. But whe= n I use the function "UDT::select" in my program(on MS visual studio.net2003), I got a run-time error : ***************************************** Debug Assertion Failed! Program: e:\try.cpp File: dbgheap.c Line: 1132 Expression: _CrtIsValidHeapPointer(pUserData) ****************************************** We cannot find where the problem is. Could you please kindly take the bothe= r to have a look at this and help to find out the reason? Look forward to you= r help! Thanks a million. Best, Leslie The source code file is as follows: //////////////////////////////////////////////////////////////////// #include <iostream> #include <udt.h> using namespace std; using namespace UDT; int main() { UDTSOCKET serv2 =3D UDT::socket(AF_INET, SOCK_STREAM, 0); sockaddr_in my_addr2; my_addr2.sin_family =3D AF_INET; my_addr2.sin_port =3D htons(22222); my_addr2.sin_addr.s_addr =3D INADDR_ANY; cout<<"server open: "<<serv2<<endl; if (UDT::ERROR =3D=3D UDT::bind(serv2, (sockaddr*)&my_addr2, sizeof(my_add= r2))) { cout << "bind: " << UDT::getlasterror().getErrorMessage(); return 0; } UDT::listen(serv2, 10); int namelen; sockaddr_in their_addr; UDTSOCKET recver =3D UDT::accept(serv2, (sockaddr*)&their_addr, &namelen); if(UDT::ERROR !=3D recver) cout<<"new client coming..."<< recver <<endl; timeval tv; UDSET tempfds; tv.tv_sec =3D 2; tv.tv_usec =3D 0; UD_ZERO(&tempfds); UD_SET(recver, &tempfds); if( UD_ISSET(recver, &tempfds)) cout<<"yes!"<<endl; bool done =3D false; int i =3D 0; Sleep(5000); while(!done) { int res =3D UDT::select(0, &tempfds, NULL, NULL, &tv); if(res =3D=3D 0 && res !=3D (UDT::ERROR)) { cout<<++i<<": "<<"time out!"<<endl; tv.tv_sec =3D 2; tv.tv_usec =3D 0; UD_ZERO(&tempfds); UD_SET(recver, &tempfds); continue; } else if( UD_ISSET(recver, &tempfds) ) { cout<<"good!"<<endl; done =3D true; } else { cout<<"what's up?"<<endl; break; } } UDT::close(serv2); return 0; } /////////////////////////////////////////////////////////////////////// |