Ok, first you need to make sure you have
multisync.h and
MultisyncDLL.lib in the same place as your source file (or just in a place where the compiler can find them), and
MultisyncDLL.dll in the directory you run the application from. Regardless of whether you already have the files or not, you'll probably need to re-download them from
here as I've just made some changes.
Server:
#include <windows.h>
#include <stdio.h>
#include "multisync.h"
int main()
{
MSG msg;
int playerNum;
char buffer[256];
if (!NetHost_IP(10, "127.0.0.1")) {
NetGetError(buffer, 256);
printf("Failed to start server: %s.n", buffer);
getchar();
return 0;
}
printf("Server started.n");
for (;;)
{
/* Handle the window message pump. This is important because Multisync
uses window events for notification */
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Check for new clients
if (playerNum = NetPlayerJoined()) { // Note that this isn't a comparison
printf("Client %i connected.n", playerNum);
}
// Check for disconnected clients
if (playerNum = NetPlayerLeft()) {
printf("Client %i disconnected.n", playerNum);
}
// Handle messages
while (NetGetMessage())
{
playerNum = NetMessageFrom();
printf("Received message from client %i (%i bytes).n", playerNum, NetGetMessageSize());
NetGetString(buffer, 256);
printf("Client #%i: %sn", playerNum, buffer);
// Send a reply
NetPutString("!Server version 1.1337!");
NetSend(playerNum);
}
}
return 0;
}
Client:
#include <stdio.h>
#include "multisync.h"
int main()
{
char buffer[256];
if (!NetConnect("127.0.0.1")) {
NetGetError(buffer, 256);
printf("Failed to connect to server: %s.n", buffer);
getchar();
return 0;
}
printf("Connected.n");
NetPutString("Did you try rotating the shield harmonics?");
NetSend(0);
printf("Message sent.n");
getchar();
return 0;
}