• Advertisement

Archived

This topic is now archived and is closed to further replies.

passing an IP address to an DirectPlay Address object

This topic is 5994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, another DP question Hope no one gets board of me asking. I am asking my user for the target ip address. All the SP details necassary are already in the address objects, but I need to pass to the app the IP address we want to connect to. Now, I can set in Peer::EnumHosts the flag "oktoqueryforaddressing" in which case the app will bring up a dialog box which asks for the remote machine's address. This is fine, but my app is DirectDraw based and the dialog box crashes the app. So I am now asking the user for the IP address directly through the app. But I need to know where that IP address should be stored, and if I should modify the string containing that IP address before I call the function that will store it. I am sure it goes somewhere in the hostAddress, but I cannot think how to put it there. Can anyone point me in the right direction? Oh yes, I should mention that I also do NOT want to copy over or delete the SP info already contained within the Address object. Edited by - Leggyguy on September 19, 2001 3:27:50 PM

Share this post


Link to post
Share on other sites
Advertisement
with VB:


objDPServerAddress.AddComponentString DPN_KEY_HOSTNAME, strServerIP
objDPServerAddress.AddComponentLong DPN_KEY_PORT, intServerPort

AppDesc.guidApplication = AppGuid
''AppDesc.lFlags = DPNSESSION_NODPNSVR
objDPClient.Connect AppDesc, objDPServerAddress, objDPClientAddress, 0, UserString, Len(UserString)

Share this post


Link to post
Share on other sites
Ah, I should have mentioned that I am working in C++, and using DirectX 8.

But thanks for the reply, ajoling.

If anyone else knows how to do what I am trying, I am still trying to figure it out.

Thanks.

Share this post


Link to post
Share on other sites
You can supply the address in string format, i.e. "" for a null address (used when doing an enumeration and you just want to do a general LAN search) or "10.0.0.25" say if you are refering to a specific address.

You can use the AddComponent() method of your IDirectPlay8Address object with pwszName=DPNA_KEY_HOSTNAME and dwDataType=DPNA_DATATYPE_STRING.

Remember that it expects a wide format Unicode string and not an Ansi string so you must convert your string first.

Your code might look something like this, where szIPAddress is the provided active parameter:



WCHAR* wszHostName = NULL;


// Set the remote host name (if provided)
if( (szIPAddress!=NULL) && (szIPAddress[0]!=0) )
{
wszHostName = new WCHAR[strlen(szIPAddress)+1];

DXUtil_ConvertGenericStringToWide( wszHostName, szIPAddress, (strlen(szIPAddress)+1)*sizeof(WCHAR) );

if( FAILED( hr = pDP8AddressHost->AddComponent( DPNA_KEY_HOSTNAME, wszHostName, (wcslen(wszHostName)+1)*sizeof(WCHAR), DPNA_DATATYPE_STRING ) ) )
{
goto CLEANUP;
}
}


Hope this helps.

Share this post


Link to post
Share on other sites
As Ajoling says the "BASIC"''s is there and they both equate to the same thing.

That is BASIC_VERSION==C++_VERSION is TRUE.

>8)

Share this post


Link to post
Share on other sites
I just want to say, thanks a lot guys.

I am at work, and haven''t tried it out yet, but it does clarify some of the documentation that I didn''t quite follow.

I am pretty sure that will clear up that detail for me. So again, thanks. I really appreciate the help. And it really nice to find people who want to help others learn.

Share this post


Link to post
Share on other sites

  • Advertisement