   IDirectPlay8Client::SetClientInfo woes
  Hi all,Trying to get to grips with DirectPlay. When calling IDirectPlay8Client::SetClientInfo asynchronously, it doesn't matter how long I wait before attempting to connect to a server; the client name is still not reported when connecting to the server.My code currently looks like the followingvoid CDPClient::SetClientName(std::string pr_strClientName) {//----- cleanup if necesaryif(dpnPlayerInfo.pwszName) delete[] dpnPlayerInfo.pwszName;//----- fill out DPN_PLAYER_INFOZeroMemory(&dpnPlayerInfo, sizeof(DPN_PLAYER_INFO));dpnPlayerInfo.dwSize= sizeof(dpnPlayerInfo);dpnPlayerInfo.dwInfoFlags= DPNINFO_NAME;AsciiToUnicodeString(pr_strClientName, dpnPlayerInfo.pwszName);//----- set player infom_pDPClient->SetClientInfo(&dpnPlayerInfo, NULL, NULL, 0);//m_pDPClient->SetClientInfo(&dpnPlayerInfo, NULL, NULL, DPNSETCLIENTINFO_SYNC);};    ... where dpnPlayerInfo is a member of the CDPClient class.If I call SetClientInfo with the DPNSETCLIENTINFO_SYNC flag set the player name is properly reported when I have connected to a server, but naturally the client's calling thread now halts for 1-2 seconds.I'm using a DirectPlay thread pool to set worker thread count to 0, so my simply console-based test code looks like:CDPClient *myclient = new CDPClient();myclient->SetClientName((std::string)"sunbeam");printf("Name set, press A to continue\n");while(!GetAsyncKeyState('A')) {myclient->DoWork();}SDPClientConnectDescription conDesc;conDesc.m_guid = appguid;conDesc.m_nPort = 2507;conDesc.m_strRemoteHost = (std::string)"127.0.0.1";printf("Client connecting... press B to end\n");myclient->Connect(conDesc);while(!GetAsyncKeyState('B')) {myclient->DoWork();}delete myclient;    ... where ->DoWork() maps into IDirectPlay8ThreadPool::DoWork().In short, if the DPNSETCLIENTINFO_SYNC is set, the client name is  sent to the server just fine. If not, it doesn't matter how long the console programs sits in the first busy-waiting loop; the client's name is still not reported correctly on the server side.Any ideas and tips would be gladly appreciated.Thanks in advanceBjørn Toft Madsen[edited by - sunbeam60 on February 17, 2004 4:45:23 AM]
  Hmm, that''s very embarrasing :-| I solved my problem; as usual having to word it started me looking for other avenues of errors.Even though the returned AsyncHandle in the ::SetClientInfo() function cannot be used, it cannot be set to NULL. If it does, the return value of the call is E_INVALIDARG. The member function now looks like:void CDPClient::SetClientName(std::string pr_strClientName) {HRESULT hr;DPNHANDLE temp;//----- cleanup if necesaryif(dpnPlayerInfo.pwszName) delete[] dpnPlayerInfo.pwszName;//----- fill out DPN_PLAYER_INFOZeroMemory(&dpnPlayerInfo, sizeof(DPN_PLAYER_INFO));dpnPlayerInfo.dwSize= sizeof(dpnPlayerInfo);dpnPlayerInfo.dwInfoFlags= DPNINFO_NAME;AsciiToUnicodeString(pr_strClientName, dpnPlayerInfo.pwszName);//----- set player infohr = m_pDPClient->SetClientInfo(&dpnPlayerInfo, NULL, &temp, 0);};  Best regardsBjørn Toft Madsen 