Here are the main.cpp files for a simple server and client. You should be able to create a 3D game project, and replace the main.cpp with these. You will want to replace the line:
#include "multisync.h"
with this one:
#include <multisync.h>
Server main.cpp
// Dark GDK - The Game Creators - www.thegamecreators.com
// Simple Telnet style server for MultiSync.
//
//
//
//
#include <DarkGDK.h>
#include "multisync.h"
#define MAX_CONNECTED 16 // Begin with modest goals.
char MultiSyncServerName[] = "MultiSync Basic Server for GDK v0.alpha";
char serverip[] = "127.0.0.1";
char tempstr[256];
bool connected = false;
int connection = 0;
int connections = 0;
int playerleft = 0;
void DarkGDK(void)
{
dbSyncOn();
dbSyncRate(60);
dbPositionCamera(10, 10, -20);
NetSetPort(23);
if (!NetHost(MAX_CONNECTED))
{
NetGetError(tempstr, 256);
MessageBox(NULL, tempstr, MultiSyncServerName, MB_ICONEXCLAMATION);
}
else MessageBox(NULL, "Ready for connections.",
MultiSyncServerName, MB_ICONINFORMATION);
while (LoopGDK())
{
dbClear(0, 0, 0);
dbText(0, 0, MultiSyncServerName);
connection = NetPlayerJoined();
if (connection != 0)
{
NetPutString(MultiSyncServerName);
NetSend(connection);
connections++;
}
playerleft = NetPlayerLeft();
if (playerleft)
{
connections--;
}
//
sprintf(tempstr, "%i connected.", connections);
dbText(0, 32, tempstr);
dbSync();
}
//
return;
}
Client main.cpp
// Dark GDK - The Game Creators - www.thegamecreators.com
// Simple Telnet style client for MultiSync.
//
//
//
//
#include <DarkGDK.h>
#include "multisync.h"
char ErrorNoConnection[] = "Could not establish connection to MultiSync Server.";
char ErrorNoConnectMessage[] = "Expected connection message.";
char MultiSyncClientName[] = "MultiSync Basic Client for GDK v0.alpha";
char serverip[] = "127.0.0.1";
char tempstr[256];
bool connected = false;
// Place forward references to functions that will be called in the game loop,
// but will appear after the call in the source file. To make a forward reference,
// simply place the function prototype here.
bool TryMultiSyncServerConnect(char* ipaddress);
void DarkGDK (void)
{
dbSyncOn();
dbSyncRate(60);
dbPositionCamera(10, 10, -20);
NetSetPort(23);
connected = TryMultiSyncServerConnect(serverip);
while (LoopGDK())
{
dbSync();
}
if (NetConnected()) NetDisconnect();
return;
}
bool TryMultiSyncServerConnect(char *ipaddress)
{
DWORD start;
sprintf(tempstr, "BUFFER CONTENT UNCHANGED.");
if (NetConnect(ipaddress))
{
start = GetTickCount();
while (GetTickCount() - start < 1000);
if (NetGetMessage()) NetGetString(tempstr, 256);
else sprintf(tempstr, ErrorNoConnectMessage);
MessageBox(NULL, tempstr,
MultiSyncClientName, MB_ICONINFORMATION);
return true;
}
else
{
MessageBox(NULL, ErrorNoConnection,
MultiSyncClientName, MB_ICONEXCLAMATION);
return false;
}
}
That will get you started with client server programming using MultiSync. I used port 23 because that is Telnet. Telnet is a good protocol to use for studying TCP/IP communications.