   DirectPlay Init Help
  I can''t seem to figure it out but Host is returing DPNERR_INVALIDDEVICEADDRESS. I read the docs and they said that means a) I used bad init code for the Address structure or b) There is already a server running on that port. I can eliminate b Because I''ve checked my net traffic and changed the port many times so that''s not the problem. So it''s my init code. I can''t find any errors though. I''ve checked all return codes (the only failed one is Host). Any ideas? Here''s the code:   void Init(){HRESULT hr;DPN_SERVICE_PROVIDER_INFO* pSP = NULL;DWORD  dwNumSP=0, dwSize=0;CoCreateInstance(CLSID_DirectPlay8Server, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Server, (void**)&pDPServer);pDPServer->Initialize(NULL, DPServerMessageHandler, 0);CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (void**)&pDPAddress);pDPAddress->SetSP(&CLSID_DP8SP_TCPIP);pDPAddress->AddComponent(DPNA_KEY_PORT, &g_Port, sizeof(DWORD), DPNA_DATATYPE_DWORD);pDPServer->EnumServiceProviders( &CLSID_DP8SP_TCPIP, NULL, pSP, &dwSize, &dwNumSP, 0 );pSP = (DPN_SERVICE_PROVIDER_INFO*)new BYTE[dwSize];hr = pDPServer->EnumServiceProviders(&CLSID_DP8SP_TCPIP, NULL, pSP, &dwSize, &dwNumSP, 0);if(FAILED(hr))cout << "EnumServiceProviders : " << hr << endl;pDPAddress->AddComponent(DPNA_KEY_PROVIDER, &pSP->guid, sizeof(GUID), DPNA_DATATYPE_GUID);delete[] pSP;ZeroMemory(&dpad, sizeof(DPN_APPLICATION_DESC));dpad.dwSize = sizeof(DPN_APPLICATION_DESC);dpad.pwszSessionName = L"MySession";dpad.pwszPassword = L"Password";dpad.dwMaxPlayers = 32;dpad.guidApplication = AppGuid;dpad.dwFlags = DPNSESSION_CLIENT_SERVER | DPNSESSION_REQUIREPASSWORD;hr = pDPServer->Host(&dpad, &pDPAddress, 1, NULL, NULL, NULL, NULL);if(FAILED(hr))cout << "Host : " << hr << endl;}Any light you could shed on this would be great.Thanks, ms 
  Im not sure what your problem is, however when I init directplay on my winXP it wont let me specify a port, I have to use port 0 and let winXP auto select a port.This is a pain because then your client has to enumerate hosts to find the serverAlthough I guess it might be good for compatibility.So I would suggest setting your port to 0 and then see if you get the same error. If you do, then you know its not the port for sure. If you dont get an error, then you know its the same problem I have, and no I dont know how to fix it. ;  Hey thanks for the idea, but it didn''t work. Any other possibilities? ;  bump;  Forget about EnumServiceProviders() since you are setting the SP yourself as TCP/IP. Otherwise you could end up with the 56K model service provider...The code below should be the bare necessities to get your server running. No password. No DPNSVR. Just TCPIP and a port number. //---- Create the device address::CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&pDeviceAddr);pDeviceAddr->SetSP(&CLSID_DP8SP_TCPIP);pDeviceAddr->AddComponent(DPNA_KEY_PORT, &g_Port, sizeof(DWORD), DPNA_DATATYPE_DWORD);//---- Host the game::ZeroMemory(&dpad, sizeof(DPN_APPLICATION_DESC));dpad.dwSize = sizeof(DPN_APPLICATION_DESC);dpad.pwszSessionName = L"MySession";dpad.dwMaxPlayers = 32;dpad.guidApplication = AppGuid;dpad.dwFlags = DPNSESSION_NODPNSVR;pDPServer->Host(&dpad, &pDPAddress, 1, NULL, NULL, NULL, NULL);;  Whoopdy-doo!! The server is now officially up and running, thank you! Do you have any code like that for the client, because my client app still doesn't work. If you need it here's what I'm currently doing: IDirectPlay8Client *StartClientServer(char* szPlayerName, char* szSessionName, char* szPassword, char* szIPAddress, DWORD dwPort){IDirectPlay8Client *pDPClient;DPN_SERVICE_PROVIDER_INFO* pSP = NULL;IDirectPlay8Address *pDPAddress, *pDPHostAddress;DPN_APPLICATION_DESC dpad;DPN_PLAYER_INFO dppi;//GUID* guidAdapter = new GUID;WCHAR wszSessionName[256];WCHAR wszPassword[256];WCHAR wszIPAddress[256];WCHAR wszPlayerName[256];CoCreateInstance(CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Client, (void**)&pDPClient);pDPClient->Initialize(NULL, DPClientMessageHandler, NULL);CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (void**)&pDPAddress);CoCreateInstance(CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (void**)&pDPHostAddress);pDPAddress->SetSP(&CLSID_DP8SP_TCPIP);pDPHostAddress->SetSP(&CLSID_DP8SP_TCPIP);mbstowcs(wszIPAddress, szIPAddress, strlen(szIPAddress)+1);pDPHostAddress->AddComponent(DPNA_KEY_HOSTNAME, wszIPAddress, (wcslen(wszIPAddress)+1)*sizeof(WCHAR), DPNA_DATATYPE_STRING);pDPHostAddress->AddComponent(DPNA_KEY_PORT, &dwPort, sizeof(DWORD), DPNA_DATATYPE_DWORD);//pDPHostAddress->AddComponent(DPNA_KEY_DEVICE, guidAdapter, sizeof(GUID), DPNA_DATATYPE_GUID);ZeroMemory(&dppi, sizeof(DPN_PLAYER_INFO));dppi.dwSize = sizeof(DPN_PLAYER_INFO);dppi.dwInfoFlags = DPNINFO_NAME | DPNINFO_DATA;mbstowcs(wszPlayerName, szPlayerName, strlen(szPlayerName+1));dppi.pwszName = wszPlayerName;pDPClient->SetClientInfo(&dppi, NULL, NULL, DPNSETCLIENTINFO_SYNC);ZeroMemory(&dpad, sizeof(DPN_APPLICATION_DESC));dpad.dwSize = sizeof(DPN_APPLICATION_DESC);dpad.dwFlags = DPNSESSION_CLIENT_SERVER;mbstowcs(wszSessionName, szSessionName, strlen(szSessionName)+1);dpad.pwszSessionName = wszSessionName;if(szPassword != NULL){mbstowcs(wszPassword, szPassword, strlen(szPassword)+1);dpad.pwszPassword = wszPassword;dpad.dwFlags |= DPNSESSION_REQUIREPASSWORD;}HRESULT hr = pDPClient->Connect(&dpad, pDPHostAddress, pDPAddress, NULL, NULL, NULL, 0, NULL, NULL, DPNCONNECT_SYNC);//DPNERR_INVALIDDEVICEADDRESSpDPAddress->Release();pDPHostAddress->Release();return pDPClient;}Thank you SO incredibly much.P.S. Connect too is giving me the DPN_ERR_INVALIDDEVICEADDRESS.   [edited by - ms291052 on February 3, 2004 7:36:36 AM];  bump ;  a) dpad.guidApplication ? Just set it...b) Make sure ''szIPAddress'' is either in the form "dp8server.gamedev.net" or "214.21.44.56". You can also use DPNENUMHOSTS_OKTOQUERYFORADDRESSING in the dpad.dwFlags so the system will pop up a dialog box with the missing item(s).c) The call may fail because you are behind a NAT. Here is what MSDN says about this:quote:If the DPNA_KEY_PORT component was set in the device address specified to IDirectPlay8Peer::EnumHosts or IDirectPlay8Peer::Connect, then DirectPlay will ask the NAT device to forward the same external port number. If that public port number is in use then the call to IDirectPlay8Peer::EnumHosts or IDirectPlay8Peer::Connect will fail with DPNERR_INVALIDDEVICEADDRESS. This might happen when another instance of the application behind the same NAT is already connected. You should design your application and match-making so that they do not require the same port to be used both locally and on the NAT device. You can then allow DirectPlay to try alternate external ports when the matching port is not available by using the DPNA_KEY_TRAVERSALMODE device address component. 