11 Replies - 619 Views - Last Post: 22 April 2010 - 09:37 PM Rate Topic: -----

#1 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

online program trial

Posted 22 April 2010 - 06:06 PM

Hi,

I am developing a game which should have online capabilities. I think I have got it all sorted but can't test it because I only have one internet network. It works across the network but what I really need to test is my port forwarding handiwork which will only become apparent in an online test. I promise this isn't a virus and that the only thing passing from your machine to mine and vice versa is a "hello world!" string to test the connection.

Thanks to anyone who downloads and tests this for me, I would be appreciative if you would post the result here. This "server" (my laptop!) will only be active for a little while until I get some results so please don't post me to say it doesn't work after I get some feedback and the error message is "TIMED OUT" as this indicates an inability to find the server which will be because it's not there any more!

EDIT: forgot the download! For some reason I can't attach a zip file so here is the MegaUpload link!

Thanks in advance

This post has been edited by rainbow evil: 22 April 2010 - 06:13 PM


Is This A Good Question/Topic? 0
  • +

Replies To: online program trial

#2 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 06:40 PM

one additional note is that if you get an error message box with letters, number and underscores before the black window loads then you haven't got the august 2007 version of DirectX 9.0c installed.

This post has been edited by rainbow evil: 22 April 2010 - 06:41 PM

Was This Post Helpful? 0
  • +
  • -

#3 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: online program trial

Posted 22 April 2010 - 06:49 PM

Quote

I promise this isn't a virus and that the only thing passing from your machine to mine and vice versa is a "hello world!" string to test the connection.
Right, because we know how much your words count.
Was This Post Helpful? 0
  • +
  • -

#4 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 06:57 PM

obviously this is true but surely if I wanted to post a virus I would be using an alias with no reputation/posts etc.

This is a work in progress so it is messy and a lot of the functions are awful but here is the source code for the "server" for those who know dark gdk and multisync:
#include "DarkGDK.h"
#include "multisync.h"
#include <dinput.h>

void hcNetHost(int players);
void hcNetHost(int players, char* ipAddress);
void hcNetConnect(char* ipAddress);

char ip[16] = "192.168.1.200";
char error[100];
char message[100];

void DarkGDK ( void )
{
	dbSyncOn();
	dbSyncRate(0);
	dbSetWindowTitle("Message Send/Receive Host Program");
	dbDisableEscapeKey();
	hcNetHost(32, ip);
	while (LoopGDK())
	{
		if (dbKeyState(DIK_ESCAPE))
		{
			NetDisconnect();
			while (LoopGDK() && !dbKeyState(DIK_RETURN))
			{
				dbCLS();
				dbText(0, 0, "Press the return key to host another server");
				dbSync();
			}
			hcNetHost(32, ip);
		}
		NetPlayerJoined();
		NetPlayerLeft();
		NetPutString("hello world!(1)");
		NetSendAll();
		dbCLS();
		dbText(dbScreenWidth() - 30, 0, dbStr((int)dbScreenFPS()));
		if (NetGetMessage())
		{
			NetGetString(message, 100);
			dbText(0, 0, message);
			dbSync();
		}
		else
		{
			dbText(0, 0, "No Messages");
			dbSync();
		}
	}
}

void hcNetHost(int players, char* ipAddress)
{
	while (LoopGDK() && !NetHost_IP(players, ipAddress))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}

void hcNetHost(int players)
{
	while (LoopGDK() && !NetHost(players))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}

void hcNetConnect(char* ipAddress)
{
	while (LoopGDK() && !NetConnect(ipAddress))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}

and here is the client code:
#include "DarkGDK.h"
#include "multisync.h"
#include <dinput.h>

void hcNetHost(int players);
void hcNetHost(int players, char* ipAddress);
void hcNetConnect(char* ipAddress);

char ip[16] = "192.168.1.200";
char error[100];
char message[100];

void DarkGDK ( void )
{
	dbSyncOn();
	dbSyncRate(60);
	dbSetWindowTitle("Message Send/Receive Client Program");
	dbDisableEscapeKey();
	hcNetConnect(ip);
	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
		{
			if (dbKeyState(DIK_ESCAPE))
			{
				NetDisconnect();
			}
			NetPutString("hello world!(2)");
			NetSend(1);
			if (NetGetMessage())
			{
				NetGetString(message, 100);
				dbText(0, 0, message);
				dbSync();
			}
			else
			{
				dbText(0, 0, "No Messages");
				dbSync();
			}
		}
	}
}

void hcNetHost(int players, char* ipAddress)
{
	while (LoopGDK() && !NetHost_IP(players, ipAddress))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}

void hcNetHost(int players)
{
	while (LoopGDK() && !NetHost(players))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}

void hcNetConnect(char* ipAddress)
{
	while (LoopGDK() && !NetConnect(ipAddress))
	{
		dbCLS();
		NetGetError(error, 100);
		dbText(0, 0, error);
		dbSync();
	}
}


If anyone who understands this could confirm that it doesn't contain any malicious stuff I would be grateful. Of course I would be more grateful if you could then test it :)

This post has been edited by rainbow evil: 22 April 2010 - 07:00 PM

Was This Post Helpful? 0
  • +
  • -

#5 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: online program trial

Posted 22 April 2010 - 07:07 PM

char ip[16] = "192.168.1.200"; Did you clean out the IP in the code you posted? (Pointless, since we can then find out from the executable!) I hope you don't think this is the real IP...
Was This Post Helpful? 0
  • +
  • -

#6 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 07:18 PM

what do you mean "clean out the IP"? this is a carbon copy of what is compiled and in the zip file. That is the static IPv4 address or something (not entirely sure, I just followed a tutorial on port forwarding and I don't know how it works)
Was This Post Helpful? 0
  • +
  • -

#7 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: online program trial

Posted 22 April 2010 - 07:25 PM

Quote

That is the static IPv4 address or something
Yeah, it's an IPv4 address. Not saying much. Almost no support for IPv6 generally. Static? Well, it's assigned by your router, right? Not very static. The problem is that your IP address is not public.

Wikipedia entry on what you did wrong.
Was This Post Helpful? 1
  • +
  • -

#8 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 07:31 PM

it is static as I assigned that address from the laptop instead of the router doing it automatically (as part of port forwarding). I guess what you're saying is that my code won't work as it doesn't have my IP address? If that's the case then do you know where should it be in the program?
Was This Post Helpful? 0
  • +
  • -

#9 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: online program trial

Posted 22 April 2010 - 07:47 PM

I don't think you've understood port forwarding, or anything fundamentally about IP addresses.

Quote

it is static as I assigned that address from the laptop instead of the router doing it automatically
You can't just give yourself an IP address. You need to obtain that. In the case of a private network, it's the router. The router is either set to always give you a certain IP address, or chooses an available IP from a pool (i.e. dynamic).

Here's the basic problem. Your ISP gives you one IP address, and you have given that to your router. Now what do you do about your computer? To solve this problem, you can have your router assign private IPs to each device on its network. But, this still doesn't solve the communication problem.

If I want to communicate from my computer to your computer, I need to use your public IP. But your public IP is given to the router, not your computer. Port forwarding means directing packets sent to a certain port to a particular computer. For example, your router can be configured to send all inbound packets on port 10000 to your computer.

Because communication is not only done on IPs, but on certain ports, I can now communicate with your computer by communicating through a particular port. In your case, you would have to tell me both the public IP, and the port that routes to your computer.

This post has been edited by Oler1s: 22 April 2010 - 07:47 PM

Was This Post Helpful? 1
  • +
  • -

#10 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 08:04 PM

ah! thanks, that helps me understand better! any idea where I would have to but the port (6993) if I were to put my router's IP in place of the static computer IPv4 thing for multisync? Wild stab in the dark as, considering this is C++ forum, you probably won't know something addon-specific!
Was This Post Helpful? 0
  • +
  • -

#11 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: online program trial

Posted 22 April 2010 - 08:13 PM

There are two obligations. Your network must be setup correctly. So your router must route everything on that particular IP to your computer. You must configure your router appropriately. Just Google for how to do this.

The second is that the client must direct all packets to that particular IP. Since you are programming the client, you need to figure this out. Check the API documentation.
Was This Post Helpful? 1
  • +
  • -

#12 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: online program trial

Posted 22 April 2010 - 09:37 PM

got it all working, found the port setting command which allowed me to connect the host and client over internet rather than just the network. Thanks for the help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1