Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualpapalazaru

Posted 06 November 2012 - 06:54 AM

Broadcast only works for computers sharing the same subnet (LAN games).

Ohterwise you need an introducer / matchmaker. These usually comes in the for of a registered domain (for which you can find the IP via a DNS lookup). It doesn't need to be, your matchmaking server could just be some machine on the net with a static IP and opened port.

Each player hosting a game would register themselves with that matchmaking server. Typically, a new session host would register himself with the matchmaking server, which will give the server the host's public IP. Then it's just a matter of keeping that session host IP and host session properties stored away for the duration of the game.

Then anyone wanting to connect to that session host would query the matchmaking server. Then the server returns the address of the session host in the query response.

The second benefit of using a matchmaking server is that it can act as an introducer for NAT punch-through, which is necessary for enabling players being routers to connect to each other.

Without a matchmaking server, you cannot know the IP address of the host. the host has to discover its own public internet address, and somehow send his IP to the client, via IM, email, or some form of game invite.

Something like this, although I'm not entirely sure about its reliability.
[source lang="cpp"]#include <windows.h>#include <wininet.h>#pragma comment(lib, "wininet")void show_ip_address(){HINTERNET hInternet, hFile;DWORD rSize;static char buffer[64];hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);hFile = InternetOpenUrl(hInternet, "http://automation.whatismyip.com/n09230945.asp", NULL, 0, INTERNET_FLAG_RELOAD, 0);InternetReadFile(hFile, &buffer, sizeof(buffer), &rSize);buffer[rSize] = '\0';InternetCloseHandle(hFile);InternetCloseHandle(hInternet);MessageBoxA(0, buffer, "", MB_OK);}[/source]

#2papalazaru

Posted 06 November 2012 - 06:52 AM

Broadcast only works for computers sharing the same subnet (LAN games).

Ohterwise you need an introducer / matchmaker. These usually comes in the for of a registered domain (for which you can find the IP via a DNS lookup). It doesn't need to be, your matchmaking server could just be some machine on the net with a static IP and opened port.

Each player hosting a game would register themselves with that matchmaking server. Typically, a new session host would register himself with the matchmaking server, which will give the server the host's public IP. Then it's just a matter of keeping that session host IP and host session properties stored away for the duration of the game.

Then anyone wanting to connect to that session host would query the matchmaking server. Then the server returns the address of the session host in the query response.

The second benefit of using a matchmaking server is that it can act as an introducer for NAT punch-through, which is necessary for enabling players being routers to connect to each other.

Without a matchmaking server, you cannot know the IP address of the host. the host has to discover its own public internet address, and somehow send his IP to the client, via IM, email, or some form of game invite.

Something like this, although I'm not entirely sure about its reliability.
[source lang="cpp"]void show_ip_address(){HINTERNET hInternet, hFile;DWORD rSize;static char buffer[64];hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);hFile = InternetOpenUrl(hInternet, "http://automation.whatismyip.com/n09230945.asp", NULL, 0, INTERNET_FLAG_RELOAD, 0);InternetReadFile(hFile, &buffer, sizeof(buffer), &rSize);buffer[rSize] = '\0';InternetCloseHandle(hFile);InternetCloseHandle(hInternet);MessageBoxA(0, buffer, "", MB_OK);}[/source]

#1papalazaru

Posted 06 November 2012 - 06:51 AM

Broadcast only works for computers sharing the same subnet (LAN games).

Ohterwise you need an introducer / matchmaker. These usually comes in the for of a registered domain (for which you can find the IP via a DNS lookup). It doesn't need to be, your matchmaking server could just be some machine on the net with a static IP and opened port.

Each player hosting a game would register themselves with that matchmaking server. Typically, the matchmaking server will find a new connection request from a new session host, which will give him the session host's public IP. Then it's just a matter of keeping that session host and session properties stored away for the duration of the game.

Then anyone wanting to connect to that session host would query the matchmaking server. Then the server simply returns the address of the session host in the query response.

The second benefit of using a matchmaking server is that it can act as an introducer for NAT punch-through, which is necessary for enabling players being routers to connect to each other.

Without a matchmaking server, you cannot know the IP address of the host. the host has to discover its own public internet address, and somehow send his IP to the client, via IM, email, or some form of game invite.

Something like this, although I'm not entirely sure about its reliability.
[source lang="cpp"]void show_ip_address(){HINTERNET hInternet, hFile;DWORD rSize;static char buffer[64];hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);hFile = InternetOpenUrl(hInternet, "http://automation.whatismyip.com/n09230945.asp", NULL, 0, INTERNET_FLAG_RELOAD, 0);InternetReadFile(hFile, &buffer, sizeof(buffer), &rSize);buffer[rSize] = '\0';InternetCloseHandle(hFile);InternetCloseHandle(hInternet);MessageBoxA(0, buffer, "", MB_OK);}[/source]

PARTNERS