🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Dx8 Address URL, Why is it so hard?

Started by
6 comments, last by Shannon Barber 23 years, 7 months ago
I give, has anyone managed to create a Dx8Address url? Specifically I want to set a server IP & port to use with IDirectPlay8Client->Connect(...)
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
I don''t see the point in using the urls. They are poorly documented anyway. Here is my Client init/connect function.


HRESULT CDPClient::Connect(GUID guidApp, LPTSTR lpHostName, DWORD dwPort)
{
USES_CONVERSION;
HRESULT hr;

DPN_APPLICATION_DESC dpnAppDesc;
IDirectPlay8Address* pdpAddrHost = NULL;
IDirectPlay8Address* pdpAddrLocal = NULL;

// Create IDirectPlay8Client
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Client, (LPVOID*)&m_pdpClient)))
return DXTRACE_ERR(_T("CoCreateInstance"), hr);

// Create IDirectPlay8LobbiedApplication
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8LobbiedApplication, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8LobbiedApplication, (LPVOID*)&m_pdpLobby)))
return DXTRACE_ERR(_T("CoCreateInstance"), hr);

// Init IDirectPlay8Client
if(FAILED(hr = m_pdpClient->Initialize( NULL, MsgHandler, 0)))
return DXTRACE_ERR(_T("Initialize"), hr );

// Init IDirectPlay8LobbiedApplication. Before this Initialize() returns
// a DPL_MSGID_CONNECT msg may come in to the DirectPlayLobbyMessageHandler
// so be prepared ahead of time.
if(FAILED(hr = m_pdpLobby->Initialize(this, MsgHandler, NULL, 0)))
return DXTRACE_ERR(_T("Initialize"), hr );

// Create the local device address object
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&pdpAddrLocal))){
return DXTRACE_ERR( _T("CoCreateInstance"), hr);
}

// Set IP service provider
if(FAILED(hr = pdpAddrLocal->SetSP( &CLSID_DP8SP_TCPIP))){
pdpAddrLocal->Release();
return DXTRACE_ERR( _T("SetSP"), hr);
}

// Create the remote host address object
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&pdpAddrHost))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("CoCreateInstance"), hr);
}

// Set IP service provider
if(FAILED(hr = pdpAddrHost->SetSP( &CLSID_DP8SP_TCPIP))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("SetSP"), hr);
}

if( lpHostName != NULL && lpHostName[0] != 0 )
{
//Add IP Address or DNS name component
hr = pdpAddrHost->AddComponent( DPNA_KEY_HOSTNAME, T2W(lpHostName), (_tcslen(lpHostName)+1)*sizeof(WCHAR), DPNA_DATATYPE_STRING);
if(FAILED(hr)){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("AddComponent"), hr);
}
//Add Port component if specified, optional
if(dwPort != 0){
hr = pdpAddrHost->AddComponent( DPNA_KEY_PORT, &dwPort, sizeof(dwPort), DPNA_DATATYPE_DWORD);
if(FAILED(hr)){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("AddComponent"), hr);
}
}
}

ZeroMemory( &dpnAppDesc, sizeof( DPN_APPLICATION_DESC ) );
dpnAppDesc.dwSize = sizeof( DPN_APPLICATION_DESC );
dpnAppDesc.guidApplication = guidApp;

hr = m_pdpClient->EnumHosts( &dpnAppDesc, pdpAddrHost, pdpAddrLocal, NULL, 0, 0, 0, 0, NULL, NULL, DPNENUMHOSTS_SYNC );
if(FAILED(hr)){
if( hr != DPNERR_INVALIDDEVICEADDRESS && hr != DPNERR_ADDRESSING){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("EnumHosts"), hr);
}
}
return hr;
}
How were you able to figure out the DP8 from the sdk? There were no directions on how to actually set it up and us it. There was basically only the examples and the simplePeer example is baffeling me with all of that windows message box stuff, i only know like a normal full screen directdraw or d3d kind of setup. It was pissing me off to the extreme, and there were NO comments!

Anyways, I am gonna use your above code if I can figure it out, it seems more straight forward. How do you get the lpHostName and dwPort though?

Basically all I want to do is setup a simple program, where I can press 1 to be a host, or 2 to connect to a host and the ip address of the host is already hard coded (its to much work right now to put in a method of getting the user to type in the ip address) and then the computers can do a simple wave to the other players like in the simplePeer example, but I dont want to use any of that "windows gui" crap, that stuff just ticks me off when they have all the sdk examples in there.

Possibility
The lpHostName parameter can be an IP Address or any valid DNS name. The dwPort parameter would be whatever you set up on the server machine, or you can leave it as 0 and it should connect to the first available session with the given GUID for the application.

And as to how I figured it out, I looked through the samples for DP8, but alot of the knowledge of how to do things came from my limited knowledge of the DP4 interfaces etc...
I ass-umed that creating a lobby required some sort of gui thing to pop-up, thanks Stelly I was betting that had figured something out already.

What does T2W do? I thought it made a wide char version of an ansi string (which seems like a ridiculuous thing to require in a network api)


I coulnd't find _any documentation on AddComponent!

Edited by - Magmai Kai Holmlor on November 25, 2000 2:21:55 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Oops, That was a bum function anyway. I was changing some things around for testing, and I copied the wrong version of that function. Here is the CORRECT one. And the T2W converts an ANSI / Multibyte / Unicode (depending on what is defined, _UNICODE, _MBCS) to Unicode. Search MSDN for ''String Conversion Macros.



HRESULT CDPClient::Connect(GUID guidApp, LPTSTR lpHostName, DWORD dwPort)
{
USES_CONVERSION;
HRESULT hr;

DPN_APPLICATION_DESC dpnAppDesc;
IDirectPlay8Address* pdpAddrHost = NULL;
IDirectPlay8Address* pdpAddrLocal = NULL;

// Create IDirectPlay8Client
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Client, (LPVOID*)&m_pdpClient)))
return DXTRACE_ERR(_T("CoCreateInstance"), hr);

// Init IDirectPlay8Client
if(FAILED(hr = m_pdpClient->Initialize(this, MsgHandler, DPNINITIALIZE_DISABLEPARAMVAL )))
return DXTRACE_ERR(_T("Initialize"), hr );

// Create the local device address object
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&pdpAddrLocal))){
return DXTRACE_ERR( _T("CoCreateInstance"), hr);
}

// Set IP service provider
if(FAILED(hr = pdpAddrLocal->SetSP( &CLSID_DP8SP_TCPIP))){
pdpAddrLocal->Release();
return DXTRACE_ERR( _T("SetSP"), hr);
}

// Create the remote host address object
if(FAILED(hr = CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&pdpAddrHost))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("CoCreateInstance"), hr);
}

// Set IP service provider
if(FAILED(hr = pdpAddrHost->SetSP( &CLSID_DP8SP_TCPIP))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("SetSP"), hr);
}

if( lpHostName != NULL && lpHostName[0] != 0 )
{
//Add IP Address or DNS name component
if(FAILED(hr = pdpAddrHost->AddComponent( DPNA_KEY_HOSTNAME, T2W(lpHostName), (_tcslen(lpHostName)+1)*sizeof(WCHAR), DPNA_DATATYPE_STRING))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("AddComponent"), hr);
}
//Add Port component if specified, optional
if(dwPort != 0){
if(FAILED(hr = pdpAddrHost->AddComponent( DPNA_KEY_PORT, &dwPort, sizeof(dwPort), DPNA_DATATYPE_DWORD))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR( _T("AddComponent"), hr);
}
}
}

ZeroMemory( &dpnAppDesc, sizeof( DPN_APPLICATION_DESC ) );
dpnAppDesc.dwSize = sizeof( DPN_APPLICATION_DESC );
dpnAppDesc.guidApplication = guidApp;


if(FAILED(hr = m_pdpClient->Connect(&dpnAppDesc, pdpAddrHost, pdpAddrLocal, NULL, NULL, NULL, 0, NULL, NULL, DPNCONNECT_SYNC))){
pdpAddrLocal->Release();
pdpAddrHost->Release();
return DXTRACE_ERR(_T("Connect"), hr);
}

return hr;
}
grrr, I''m beginning to think that writing my own priority packet queue and reliability on demand udp would be easier than jsut getting DP to connect.

	if(FAILED(hr=m_pDPClient->Connect(&m_dpnAppDesc, m_pHostAddr, 0, 0, 0, 0, 0, 0, &m_dpnhConnect, 0)))		return DXTRACE_ERR( _T("Connect"), hr);	DXTRACE_ERR( _T("Connect"), hr); 

on my connect call I''m getting
Connect (hr=Unknown (0x0015800e))
as the hr result!

before I kept getting real errors, and manage to work through the code and figure out what I was doing wrong
(cavet: don''t release the IDirectPlay8Address* you pass into Connect before it completes )


!!!Holuya! I was using different ports in the server than the client

I got a DPN_MSGID_INDICATE_CONNECT!!!
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
THAT MEANS YOU''RE MONEY! =)

This topic is closed to new replies.

Advertisement