Well, after 2 days of searching, trying, searching and trying I have given up. For some reason my client program won''t find my host program. I''ve checked the code over and over again without finding anything (although I''m new to this so the chance of me finding something might be small). By the way, the code is more or less the same as the network core from Jim Adams book "Programming role playing games with DirectX". And as I have looked through his code examples I am pretty sure that my own client and host baseclasses are working.
This is my program code for the host:
bool CHost::Create(HINSTANCE hInst, int width, int height, bool fullscreen, string title, WNDPROC proc)
{
// some init code ..................
if(!m_Adapter.Init())
return false;
if(!m_Server.Init())
return false;
// this goes as, .Host(adapter_guid, port, name, password, max players)
if(m_Server.Host(m_Adapter.GetGUID(0), 9123, "Bauer", 0, 2))
m_ClearColor = D3DCOLOR_XRGB(255, 0, 0);
else
return false;
return true;
}
// Main loop
int CHost::Run()
{
if(!Create(m_hInstance, 300, 300, false, "NetTest Host", MsgProc))
{
return -1;
}
for(;;)
{
m_Input.Update();
if(m_Input.KeyDown(DIK_ESCAPE) || !LookForQuit())
break;
m_Graphics.Clear(m_ClearColor);
m_Graphics.BeginScene();
m_Graphics.EndScene();
m_Graphics.Display();
}
Destroy();
return 0;
}
And this is the code for the client:
bool CClient::Create(HINSTANCE hInst, int width, int height, bool fullscreen, string title, WNDPROC proc)
{
// some init code ..................
if(!m_Adapter.Init())
return false;
if(!m_Client.Init())
return false;
// .Connect(adapter_guid, server_ip, port, name, session_name)
if(m_Client.Connect(m_Adapter.GetGUID(0), "127.0.0.1", 9123, "Bauer", "Bauer") == true)
m_ClearColor = D3DCOLOR_XRGB(255, 255, 0);
else
return false;
return true;
}
// Main program loop
int CClient::Run()
{
if(!Create(m_hInstance, 300, 300, false, "NetTest Client", MsgProc))
{
ShowError("Create() failed");
return -1;
}
for(;;)
{
m_Input.Update();
if(m_Input.KeyDown(DIK_ESCAPE) || !LookForQuit())
break;
m_Graphics.Clear(m_ClearColor);
m_Graphics.BeginScene();
m_Graphics.EndScene();
m_Graphics.Display();
}
Destroy();
return 0;
}
// ConnectComplete()
bool CClient::ConnectComplete(DPNMSG_CONNECT_COMPLETE *msg)
{
if(msg->hResultCode == S_OK)
{
m_bConnected = true;
ShowError("Connect complete true");
}
else
{
m_bConnected = false;
ShowError("Connect Complete false");
}
return true;
}
The problem I am having is this. The server can start to host a session, and I always get "true" returned from m_Client.Connect(), no matter which ip I put in. But I always get a "false" from ConnectComplete, so I believe that I am never connected? Any of you that have a clue what might be wrong? Both programs use the same GUID, although I took that GUID from an example program from the book. If I have to make a unique GUID for my program to work, how do I create the GUID?
Thanks alot for reading!
''Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.'' -Rich Cook
[Taken from GameDev''s random quotes.]