🎉 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!

Question about IDirectPlay8Client::Connect

Started by
5 comments, last by StarGamer_Nick 23 years, 2 months ago
Hi all, I was wondering if anyone was familar with IDirectPlay8Client::Connect functions because I''m trying to establish a connection between my server and my client. I know that my server is working but I can''t seem to find how to connect my client without using EnumHost or something like that. Anyway, if anyone has an idea it would be welcome Nick
Advertisement
This is off my client im working on, it''s in VB6/DX8 but pretty much the same thing..

Public Sub InitDP()
Dim AppDesc As DPN_APPLICATION_DESC ''Application Description
Dim TimeDesc As DPN_CAPS ''Connection Description

''Initialize DirectPlay
Set oDX8 = New DirectX8
Set oDP = oDX8.DirectPlayClientCreate
Set oServerAddy = oDX8.DirectPlayAddressCreate
Set oClientAddy = oDX8.DirectPlayAddressCreate

''Register Message Handler
oDP.RegisterMessageHandler frmMain

''Set up local address
oClientAddy.SetSP DP8SP_TCPIP

''Set up server address
oServerAddy.SetSP DP8SP_TCPIP
oServerAddy.AddComponentLong DPN_KEY_PORT, SERV_PORT
oServerAddy.AddComponentString DPN_KEY_HOSTNAME, SERV_ADDY

''Initialize AppDesc
AppDesc.guidApplication = AppGuid
TimeDesc = oDP.GetCaps(0)
TimeDesc.lConnectRetries = 6
oDP.SetCaps TimeDesc, 0

''Connect
oDP.Connect AppDesc, oServerAddy, oClientAddy, 0, ByVal 0&, 0

End Sub
-Wuzzbent

Thanks,
I tried that (under Visual C++) but it didn''t work.

My port is similar on the Server and the Client, so is the GUID.
Is the Caps functions necessary ? (I''ve tried with and without it and it didn''t work either).


Anyway, any new input would be welcome


Nick



No the Cap const is not required, I just use that so if the server is down, it doesn''t take 135 seconds to detect the server isn''t up, setting it at 6 changes it to 25 seconds, plenty long enough.. Umm make sure your AppGUID are exactely the same on the server and client right? If not they need to be, umm, the SERV_ADDY and SERV_PORT are consts, you need to declare them before using them.. Hmm, anything else... Oh yea make sure you''re SERV_PORT and CLIENT_PORT are the same to bind with.. The client will find it''s own incoming port automatically.. Well other than that, that code works great on my machine..

-Wuzzbent
-Wuzzbent
I think that problem might be because I''m using the
DPNCONNECT_OKTOQUERYFORADDRESSING flags when initating connect.
I''ve removed it but I seem to have a problem adding my Server addy to the host address. I use a call to

hr = g_dpHostAdd->AddComponent( DPNA_KEY_HOSTNAME, ServerName, sizeof((*ServerName)),DPNA_DATATYPE_STRING );

where ServerName is LPSTR ServerName=Text("");

I''m trying to connect to my own server via my own computer (like in the sample if you put nothing in the connection area).

I think the problem might be there..


Nick

Well what address are you using to connect to your own server? Using the local loop back (127.0.0.1) should work just fine.. I dont'' think you would need to use the DPNCONNECT_OKTOQUERYFORADDRESSING flag..

-Wuzzbent
-Wuzzbent
By my own server I meant my own computer, the same one has the client.

Using the AddressingQuery and putting loop back you mention it worked ! (I thought I had to put nothing to make the loopback work.. doh!..).


Only question I have now is regarding how to pass that address into my ServerName value. I tried a few things but it didn''t seem to work. How do you pass the server address into the variable ?

Nick


This topic is closed to new replies.

Advertisement