Jenkins Software

Tutorial code sample 1
Instantiation and destruction.

This is the base code to instantiate and destroy a peer as client or a server, along with some simple user input.

#include <stdio.h>
#include "RakNetworkFactory.h"
#include "RakPeerInterface.h"

#define MAX_CLIENTS 10
#define SERVER_PORT 60000

int main(void)
{
	char str[512];
	RakPeerInterface *peer = RakNetworkFactory::GetRakPeerInterface();
	bool isServer;
	
	printf("(C) or (S)erver?\n");
	gets(str);
	if ((str[0]=='c')||(str[0]=='C'))
	{
		peer->Startup(1,30,&SocketDescriptor(), 1);
		isServer = false;
	} else {
		peer->Startup(MAX_CLIENTS, 30, &SocketDescriptor(SERVER_PORT,0), 1);
		isServer = true;
	}


	// TODO - Add code body here
	
	RakNetworkFactory::DestroyRakPeerInterface(peer);

	return 0;
}