Peer to Peer networking

Started by
28 comments, last by nivlekio 16 years, 1 month ago
One solution is using UDP repeater.

First application that starts spawns the repeater process.

Repeater is a standalone process that handles broadcast notifications. It acts as some sort of singleton. When an application tries to broadcast, it checks if repeater process is running. If it isn't, it spawns it, if it is, it sends messages to it.

Repeater monitors clients that are connected to it. When last client disconnects, repeater shuts down.

This is a somewhat convenient solution for applications which are likely to need access to same port.

It can be implemented in application itself, but that makes the whole process slightly more complex, since clients must negotiate who'll become the new repeater if application that hosted the original one is shut down.
Advertisement
Quote:you can add a randomly generated number (that is unique to your application) at the start of the packet


Actually, I prefer something non-random, such as the name of the game/application as a (short) string.

A cryptographic nonce is something that you can generate per session and exchange, or something that both sides know about; it's not quite the same thing. Specifically, you could have a new nonce per packet (if you include the nonce in the packet). I've come across cases where that seemed to make sense.

A UDP repeater is a useful tool, but the "check if it's running, else spawn one" process will suffer from race conditions, where more than one client will spawn the repeater. The way to solve that is for repeaters to detect other repeaters, and shut themselves down according to some rule. One rule that works OK is for a repeater to shut itself down when it sees another repeater with a numerically lower IP address. Note that you want to tell any clients you have already seen about the shutdown, so they don't have to wait for timeout before the go looking for the new repeater.
enum Bool { True, False, FileNotFound };
Hey all having some problems trying to use my prog on a diffrent pc i have three files so far main.cpp, Sock.h and Sock.cpp I include the Sock.h in both the main and Sock.cpp the Sock.h has #include <winsock2.h> #include <stdio.h> and in main.cpp i have #include <iostream> #include <string> #include <stdio.h> #include <conio.h>.

when i run the prog on my pc it works fine but when i run it on any other pc i this error on these lines "Programe failed to start try reinstalling programe".

Whats going on? do i need some dll files to use on the other pc's if so how do i get them? Btw is there like a win32 sdk you need to install like DX9.0c sdk?
Quote:I include the Sock.h in both the mai........


Does your program compile and generate an exe?

Do you use Visual Studio?

If so, you need to provide Visual Studio redistributable run-time.

vcX0_redist.exe, where X is the internal version number of MVS (7,8 or 9). It's located in a redist directory somewhere in your MVS installation. Install that on target computer.


If not MVS, posting a more detailed error might help.
Quote:
'OgreNetwork.exe': Loaded 'C:\OgreNetwork Copy UDP\Debug\OgreNetwork.exe', Symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcp80d.dll', Symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll', Symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\wininet.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\normaliz.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\iertutil.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\urlmon.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\mswsock.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\dnsapi.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\winrnr.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\Program Files\Bonjour\mdnsNSP.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\iphlpapi.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\rasadhlp.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\hnetcfg.dll', No symbols loaded.
'OgreNetwork.exe': Loaded 'C:\WINDOWS\system32\wshtcpip.dll', No symbols loaded.
The program '[5716] OgreNetwork.exe: Native' has exited with code 0 (0x0).


Is that what you mean by "If so, you need to provide Visual Studio redistributable run-time."

If not what do you mean?

The error only occurs when i run it on another pc all it says is

Quote:
Networking.exe

This aplication has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem
Antheus means you need to supply the end user (i.e., the other computer) with a copy of Visual Studio's run-time library. It's a set of DLL's, controls, etc., that programs developed under Visual Studio may use, and they must be installed on the client system for (most) programs to work. Every person who uses your software must install (or have installed) a copy of these run-times. That's the first thing you should check.

GDNet+. It's only $5 a month. You know you want it.

Where can i find this .exe that installs the "Visual Studio's run-time library" on a pc that does not have VS2005? Ive search high and low on my pc. Could you give me like a common directory where it could be found? I looked under c:\ program files and look at the mircosoft VS folders found nothing.
Quote:Original post by nivlekio
Where can i find this .exe that installs the "Visual Studio's run-time library" on a pc that does not have VS2005? Ive search high and low on my pc. Could you give me like a common directory where it could be found? I looked under c:\ program files and look at the mircosoft VS folders found nothing.


[google] is your friend. Microsoft Visual C++ 2005 Redistributable Package (x86)

[Edited by - swiftcoder on February 25, 2008 7:38:49 PM]

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

2005

2008

Also, bare files are in, %MVS_DIR%/vc/redist/x86/, usually the .CRT variant for no UI stuff.
ok kool thanks guys ill give that a bash :)

This topic is closed to new replies.

Advertisement