Hi,
I am using the MultiSync header file in DarkGDK and have got the hang of making a program which can communicate with another on the same computer by using the IP "127.0.0.1" but this IP doesn't work for online connection. I have tried using my IP which I got from
http://www.ip-adress.com/ but that didn't work either for some reason. Here is my server code:
#include "DarkGDK.h"
#include "multisync.h"]
void DarkGDK ( void )
{
dbSyncOn();
dbSyncRate(60);
dbSetWindowTitle("Message Send/Receive Program");
char error[100];
char message[100];
while (LoopGDK() && !NetHost(2))
{
NetGetError(error, 100);
dbText(0, 0, error);
dbSync();
}
while (LoopGDK())
{
NetPlayerJoined();
NetPutString("hello world!(1)");
NetSend(1);
dbCLS();
if (NetGetMessage())
{
NetGetString(message, 100);
dbText(0, 0, message);
dbSync();
}
else
{
dbText(0, 0, "No Messages");
dbSync();
}
}
}
and here is my client code:
#include "DarkGDK.h"
#include "multisync.h"
char ip[16] = "86.15.150.106";
void DarkGDK ( void )
{
dbSyncOn();
dbSyncRate(60);
dbSetWindowTitle("Message Send/Receive Program");
char error[100];
char message[100];
while (LoopGDK() && !NetConnect(ip))
{
NetGetError(error, 100);
dbText(0, 0, error);
dbSync();
}
while (LoopGDK())
{
dbCLS();
if (!NetConnected())
{
NetGetError(error, 100);
if (strstr(error, "CONNECTION FAILED") || strstr(error, "TIMED OUT"))
{
strcpy(error, "The server is down. Attempting to re-establish connection...");
dbText(0, 0, error);
dbSync();
NetConnect("127.0.0.1");
}
else
{
dbText(0, 0, error);
dbSync();
}
}
else
{
NetPutString("hello world!(2)");
NetSend(1);
if (NetGetMessage())
{
NetGetString(message, 100);
dbText(0, 0, message);
dbSync();
}
else
{
dbText(0, 0, "No Messages");
dbSync();
}
}
}
}
I know this isn't a very complex or probably even well written piece of code but I feel that is beside the point! The server successfully creates the game but the client gets stuck in the connect loop.
Thanks in advance
good things come to those who rate!
"I hate you all" - Simon Nicholls