RakNet is a cross platform, open source, C++ networking engine for game programmers.

Overview

RakNet 4.081

Copyright (c) 2014, Oculus VR, Inc.

Package notes

The Help directory contains index.html, which is full help documentation in HTML format The Source directory contain all files required for the core of Raknet and is used if you want to use the source in your program or create your own dll The Samples directory contains code samples and one game using an older version of Raknet. The code samples each demonstrate one feature of Raknet. The game samples cover several features. The lib directory contains libs for debug and release versions of RakNet and RakVoice There is a make file for linux users in the root directory. Windows users can use projects under Samples\Project Samples

C# support

See Help\swigtutorial.html

Upgrading from version 3

See 3.x_to_4.x_upgrade.txt

Windows users (Visual Studio 2008 and 2010)

Load RakNet_VS2008.sln and convert if necessary.

After the project conversion, if you encounter error MSB4006, follow the steps below to fix it:

  1. Open project properties
  2. Click on "Common Properties"
  3. Click on "Framework and References"
  4. Look under "Build Properties"
  5. Change the "Copy Local" flag from "True" to "False"

For other compiler issues, please see Help/compilersetup.html

Windows users (VC6)

Not supported, but you can get by if you directly include the source.

CYGWIN users

Copy Include, Source, and whatever you want to run in the home directory. Then type g++ ../../lib/w32api/libws2_32.a *.cpp You can run a.exe. You might have to copy *.dll from cygwin\bin as well.

Linux users

Use cmake, or g++ -lpthread -g *.cpp in the /Source directory. With libcat, use g++ -pthread -g -I./../DependentExtensions *.cpp in the /Source directory.

64 bit use -m64 command line Sometimes you need -pthread instead of -lpthread

Command to build 64 bit chat example server from the /Source directory:

g++ -m64 -g -lpthread -I./ "../Samples/Chat Example/Chat Example Server.cpp" *.cpp

Command to build NATCompleteServer from the Samples/NATCompleteServer directory:

g++ -g -lpthread -I./ -I./../../Source main.cpp -I./../CloudServer ./../../Source/*.cpp ./../CloudServer/CloudServerHelper.cpp

Command to build autopatcher server from /Source directory:

g++ -lpthread -lpq -lssl -lbz2 -lssl -lcrypto -L/opt/PostgreSQL/9.0/lib -L../DependentExtensions/bzip2-1.0.6 -I/opt/PostgreSQL/9.0/include -I../DependentExtensions/bzip2-1.0.6 -I./ -I../DependentExtensions/Autopatcher -I../DependentExtensions/Autopatcher/AutopatcherPostgreRepository -I../DependentExtensions/PostgreSQLInterface -g *.cpp ../DependentExtensions/Autopatcher/AutopatcherServer.cpp ../DependentExtensions/Autopatcher/CreatePatch.cpp ../DependentExtensions/Autopatcher/MemoryCompressor.cpp ../DependentExtensions/Autopatcher/AutopatcherPostgreRepository/AutopatcherPostgreRepository.cpp ../DependentExtensions/PostgreSQLInterface/PostgreSQLInterface.cpp ../Samples/AutopatcherServer/AutopatcherServerTest.cpp

Command to build NATCompleteServer from /Source directory:

g++ -lpthread -I./ -I../Samples/CloudServer ../Samples/CloudServer/CloudServerHelper.cpp ../Samples/NATCompleteServer/main.cpp *.cpp

Command to build BigPacketTest from /Source directory:

g++ -lpthread -I./ ../Samples/BigPacketTest/BigPacketTest.cpp *.cpp

Or with debugging info on:

g++ -g -lpthread -I./ ../Samples/BigPacketTest/BigPacketTest.cpp *.cpp

If you get /usr/local/lib/libraknet.so: undefined reference to `__sync_fetch_and_add_4 then build with -march=i686

To debug: http://www.unknownroad.com/rtfm/gdbtut/gdbstack.html http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html http://linux.bytesex.org/gdb.html http://www.delorie.com/gnu/docs/gdb/gdb_29.html

gdb ./a.out

Set breakpoint:

b file:line

Disable a breakpoint:

disable <breakpointNumber>

Delete a breakpoint:

delete <breakpointNumber>

Get a list of breakpoints:

info breakpoints

St breakpoint to be ignored that number of times

ignore <breakpointNumber> <count>
run

Other useful commands:

info stack
info locals
delete (Clears all breakpoints)
step (step into)
next (step over)
finish (step out)
continue to keep going after step or next
p <variableName>
For example: p users.orderedList.listArray[0].guid

Command to install g++

sudo apt-get install gcc-c++
sudo apt-get install build-essential

Or:

yum install gcc-c++

Or:

sudo apt-get update
sudo apt-get install g++

Command to install gdb

sudo apt-get install gdb

Command to install wget, used to download files from webpages sudo apt-get install wget

Series of commands for a new server: sudo apt-get install wget sudo apt-get update sudo apt-get install --fix-missing g++ sudo apt-get install gdb cd RakNet_Install_Directory\Source g++ -m64 -g -pthread -I./ "../Samples/Chat Example/Chat Example Server.cpp" *.cpp ./a.out

Mac Users

Open a Terminal window and type:

cd ~/Desktop/RakNet/Source
g++ -c -DNDEBUG -I -isysroot /Developer/SDKs/MacOSX10.5u.sdk/ -arch i386 *.cpp

Use whichever SDK you have. However, the 10.4 SDK is bugged and will not compile unless you use GCC 4.0 from inside XCODE

The sources should build cleanly. This gives you a bunch of PowerPC binaries, compiled against the 10.3.9 SDK which is a good thing.

Give the following command:

libtool -static -o raknetppc.a *.o

This will stitch together a static library for the PowerPC architecture. There may be warnings that some .o files do not have any symbols. If you want to be prudent, remove the named files (the .o files, not the .cpp files!) and re-run the libtool command.

Now, we build the source files for Intel:

gcc -c -I ../Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 *.cpp

..and stitch it into a i386 library:

libtool -static -o rakneti386.a *.o

Now, type:

ls *.a

which should list the two .a files. Now, we make them into a universal binary:

lipo -create *.a -o libraknet.a

You now have a file named libraknet.a. This is the RakNet library, built to run on both PowerPC and Intel Macs. Enjoy! ;-)

IPod

Depending on what version you target, you may have to change two defines to not use 64 bit integers and floats or doubles.

Android

You will need the latest CYWGIN and the android SDK to build native code on the android. Under CYWGIN, you will need to run ndk-build on a directory for RakNet.

  1. Under cygwin, create the RakNet directory somewhere, such as under samples. For example, if you create the path \cygwin\home\Kevin\android-ndk-r4b\samples\RakNet

  2. I copied the Android.Manifest.xml and other files from another sample

  3. Under jni, you will need the following Android.mk

    LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := RakNet MY_PREFIX := $(LOCAL_PATH)/RakNetSources/ MY_SOURCES := $(wildcard $(MY_PREFIX)*.cpp) LOCAL_SRC_FILES += $(MY_SOURCES:$(MY_PREFIX)%=RakNetSources/%) include $(BUILD_SHARED_LIBRARY)

This version of Android.mk assumes there is a directory called RakNetSources, for example cygwin/home/Kevin/android-ndk-r4b/samples/RakNet/jni/RakNetSources

Under RakNetSources should be the /Source directory to RakNet. Rather than copy the files I used junction.exe http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

The command I used to create the junction was:

D:/cygwin/home/Kevin/android-ndk-r4b/samples/RakNet/jni/junction.exe -s D:/cygwin/home/Kevin/android-ndk-r4b/samples/RakNet/jni/RakNetSources D:/RakNet4/Source

To unjunction I used:

D:/cygwin/home/Kevin/android-ndk-r4b/samples/RakNet/jni/junction.exe -d D:/cygwin/home/Kevin/android-ndk-r4b/samples/RakNet/jni/RakNetSources

From within the CYWGIN enviroment, navigate to home/Kevin/android-ndk-r4b/samples/RakNet. Then type

../../ndk-build

Everything should build and you should end up with a .so file.

You should then be able to create a project in eclipse, and import cygwin/home/Kevin/android-ndk-r4b/samples/RakNet

Native client

Solution: RakNet_NativeClient_VS2010. See Samples\nacl_sdk\RakNet_NativeClient_VS2010\HowToSetup.txt for detailed instructions on setup.

Windows Phone 8

Example solution: RakNet_WinPhone8_VS2012. Add to your project DependentExtensions\WinPhone8\ThreadEmulation.cpp Add DependentExtensions\WinPhone8\ to your include paths Define _CRT_SECURE_NO_WARNINGS and WINDOWS_PHONE_8

Windows Store 8

Example solution: RakNet_WindowsStore8_VS2012.sln Add to your project DependentExtensions\WinPhone8\ThreadEmulation.cpp Add DependentExtensions\WinPhone8\ and DependentExtensions\WinRT to your include paths TCP is not supported, only UDP (RakPeer). IPV4 only (not hard to also add IPV6 upon request). Define: _CRT_SECURE_NO_WARNINGS WINDOWS_STORE_RT _RAKNET_SUPPORT_TCPInterface=0 _RAKNET_SUPPORT_PacketizedTCP=0 _RAKNET_SUPPORT_EmailSender=0 _RAKNET_SUPPORT_HTTPConnection=0 _RAKNET_SUPPORT_HTTPConnection2=0 _RAKNET_SUPPORT_TelnetTransport=0 _RAKNET_SUPPORT_NatTypeDetectionServer=0 _RAKNET_SUPPORT_UDPProxyServer=0 _RAKNET_SUPPORT_UDPProxyCoordinator=0 _RAKNET_SUPPORT_UDPForwarder=0

Unreal engine

See https://udn.epicgames.com/lists/showpost.php?list=unprog3&id=37697&lessthan=&show=20

Issues
  • Fix buffer overflow in chat server example

    Fix buffer overflow in chat server example

    message, which contains at most 2048 bytes, was previously copied after a prefix into message2, which has a size of 2048 bytes, with no bounds checking. This could result in a stack overflow of strlen("Server: ") bytes.

    opened by Ralith 9
  • Android compilation fail

    Android compilation fail

    Hello, when I try to build RakNet for Android with cygwin, I get this error :

    jni/RakNetSources/FileList.cpp:18:20: fatal error: asm/io.h: No such file or directory
     #include <asm/io.h>
    
    opened by antlafarge 5
  • Update CMake files to follow standard conventions

    Update CMake files to follow standard conventions

    This change builds the shared library on Linux as "libraknet.so" instead of "libRakNetDLL.so".

    On Linux, it is common for library names to be lowercase, and the removal of "DLL" is done for a pretty obvious reason. It's certainly not a DLL on Linux, is it?

    opened by JohnMH 3
  • Build fails for Android: Enabling LIBCAT_SECURITY for Android builds fail - no pthread_cancel()

    Build fails for Android: Enabling LIBCAT_SECURITY for Android builds fail - no pthread_cancel()

    I'm wanting to enable libCat security on Android but it fails to compile due to cat/src/threads/Threads.cpp calling pthread_cancel(..) in Threads::AbortThread().

    My research suggests that Android/NDK does not support pthread_cancel(..)

    Threads.cpp is included in RakNet/SecureHandshake.cpp

    Is there a workaround for this?

    I'm building using android-ndk-r10d-linux specifying android-9 as the platform target.

    Solved: In case anyone else is having this issue, it's very simple to fix.

    You just need to define CAT_NO_ENTROPY_THREAD in cat/Config.hpp.

    This removed the thread call completely and building is successful!

    opened by larku 2
  • is conpatiple white gnu

    is conpatiple white gnu

    this lincense is bsd of common doc and compatible white all open source lincense,and no legal change of the format of before, is only text a diferent for legal compatiple whit gnu gpl.

    opened by raiogam 2
  • uint24_t does not work on Big-Endian systems

    uint24_t does not work on Big-Endian systems

    This code in a Big-Endian system: RakNet::uint24_t test(0); test++; printf("%u\n", test.val); will print 0 and not the expected 1.

    I will try to solve it and post a solution in a comment.

    opened by ghost 1
  • Fix possible buffer overrun

    Fix possible buffer overrun

    these arrays may be accessed at (1..512) below

    for (int i=0; i < 512 && i < numParameters; i++)
    {
        dataArray[i+1]=data[i];
        lengthsArray[i+1]=lengths[i];
    }   
    
    opened by jarikomppa 1
  • how to understand

    how to understand "bool CCRakNetSlidingWindow::GreaterThan(DatagramSequenceNumberType a, DatagramSequenceNumberType b)" ?

    in the CCRakNetSlidingWindow,

    bool CCRakNetSlidingWindow::GreaterThan(DatagramSequenceNumberType a, DatagramSequenceNumberType b)
    {
    	// a > b?
    	const DatagramSequenceNumberType halfSpan =(DatagramSequenceNumberType) (((DatagramSequenceNumberType)(const uint32_t)-1)/(DatagramSequenceNumberType)2);
    	return b!=a && b-a>halfSpan;
    }
    // ----------------------------------------------------------------------------------------------------------------------------
    bool CCRakNetSlidingWindow::LessThan(DatagramSequenceNumberType a, DatagramSequenceNumberType b)
    {
    	// a < b?
    	const DatagramSequenceNumberType halfSpan = ((DatagramSequenceNumberType)(const uint32_t)-1)/(DatagramSequenceNumberType)2;
    	return b!=a && b-a<halfSpan;
    }
    
    

    how the understand the two comparision function, what the 'half span' mean ?

    opened by yandaren 0
  • SWIG and C# support for unity3d

    SWIG and C# support for unity3d

    IPod Depending on what version you target, you may have to change two defines to not use 64 bit integers and floats or doubles.

    IOS on armv7 architecture work is normal, but can't work on arm64 architecture, how to modify the source code to the right job? Help me! Thank you very much!

    Also does not support c + + 11 standards, build failures.

    opened by scc172fly 0
  • sendto return -1 and errno is EPERM on ios10.2

    sendto return -1 and errno is EPERM on ios10.2

    Before iphone upgrade to ios10.2, all going well, after upgrade can not connect. sendto returns -1 and errno is 1(EPERM). When I connect a NAT64 wifi, all going well again, why? Please help me!

    opened by zaffix 0
  • Removed the unsetting of ${libPortAudioCpp}

    Removed the unsetting of ${libPortAudioCpp}

    I was trying to use your cmake-file for one of my projects, though it didn't find the cpp-library correctly. Took a quick peek in the file and found that the variable was unset quickly after it was set and just before it was used. This pull request corrects this.

    opened by Rovanion 0
  • forbids comparison between pointer and integer

    forbids comparison between pointer and integer

    g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 building by cmake in Ubuntu20.04

    RakNet/Source/ReplicaManager3.cpp:141:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 141 | if (GetConnectionByGUID(participantListIn[index], worldId)==false)

    opened by chanseulkim 1
  • Raknet Issue on Startup Minecraft Server

    Raknet Issue on Startup Minecraft Server

    [36m07:10:50 [ERROR] An exception occurred in RakNet (Server)

    io.netty.channel.unix.Errors$NativeIoException: sendToAddress(..) failed: Invalid argument

    How can i solve this problem? I use Powernukkit for Minecraft BE

    opened by MonoAdrian23 0
  • 64bit ARM

    64bit ARM

    cmake does not seem to recognise a 64bit ARM system so the make files produced won't complete a build cycle, since there is no sys/io on arch64 systems

    /home/brian/RakNet/Source/FileList.cpp:24:10: fatal error: sys/io.h: No such file or directory #include <sys/io.h>

    any advice on a quick cmake fix?

    opened by BrianBeuken 1
  • Mac OSX Instruction Update + lipo error

    Mac OSX Instruction Update + lipo error "rakneti386.a and raknetppc.a have the same architectures (i386) and can't be in the same fat output file"

    Using the instructions for building on Mac OSX, this command:

    lipo -create *.a -o libraknet.a
    

    produces the following error:

    fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: rakneti386.a and raknetppc.a have the same architectures (i386) and can't be in the same fat output file

    I assume this is likely due to out-of-date instructions, because for example Mac OSX SDK now lives here:

    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
    

    whereas in the README.md file it is listed as /Developer/SDKs/MacOSX10.5u.sdk/. In modern version of Mac OSX, all of the /Developer/SDK stuff lives inside of the Xcode application.

    opened by netpoetica 0
  • splitPacketCount vulnerability

    splitPacketCount vulnerability

    A corrupt packet with a high value for splitPacketCount can cause either a crash (bad_array_new_length exception) or an infinite loop in the call to newChannel->splitPacketList.Preallocate.

    Such a corrupted packet could arise by chance or be crafted by a malicious user to cause a server or peer to crash. After running into the issue in the wild, I found that the issue was briefly raised on the RakNet forums here but no fix was deployed: http://www.raknet.com/forum/index.php?topic=5253.msg21668#msg21668

    My local fix was to change this block in ReliabilityLayer::CreateInternalPacketFromBitStream from:

    	if (readSuccess==false ||
    		internalPacket->dataBitLength==0 ||
    		internalPacket->reliability>=NUMBER_OF_RELIABILITIES ||
    		internalPacket->orderingChannel>=32 || 
    		(hasSplitPacket && (internalPacket->splitPacketIndex >= internalPacket->splitPacketCount)))
    	{
    		// If this assert hits, encoding is garbage
    		RakAssert("Encoding is garbage" && 0);
    		ReleaseToInternalPacketPool( internalPacket );
    		return 0;
    	}
    

    to

    	const int maxPacketSize = 1024 * 1024 * 4;
    	const int maxPacketSplit = (maxPacketSize + (MINIMUM_MTU_SIZE - 1)) / MINIMUM_MTU_SIZE;
    	if (readSuccess==false ||
    		internalPacket->dataBitLength==0 ||
    		internalPacket->reliability>=NUMBER_OF_RELIABILITIES ||
    		internalPacket->orderingChannel>=32 || 
    		internalPacket->splitPacketCount > maxPacketSplit ||
    		(hasSplitPacket && (internalPacket->splitPacketIndex >= internalPacket->splitPacketCount)))
    	{
    		// If this assert hits, encoding is garbage
    		RakAssert("Encoding is garbage" && 0);
    		ReleaseToInternalPacketPool( internalPacket );
    		return 0;
    	}
    

    However, my fix limits packet sends to 4 megabytes, which is more than enough for my projects, but is not suitable for RakNet as a whole.

    Perhaps a better fix is to define the maximum packet size in RakNetDefines.h to allow users to easily override. The maximum should also be enforced in RakPeer::Send and similar functions.

    opened by C0lumbo 0
Owner
Facebook Archive
These projects have been archived and are generally unsupported, but are still available to view and use
Facebook Archive
WAFer is a C language-based software platform for scalable server-side and networking applications. Think node.js for C programmers.

WAFer WAFer is a C language-based ultra-light scalable server-side web applications framework. Think node.js for C programmers. Because it's written i

Riolet Corporation 692 Jun 3, 2022
Our own modification of RakNet used in open.mp

RakNet 2.52 This is a modified version of RakNet 2.52 used in open.mp. Modifications are done to work with SA:MP version of RakNet with some additiona

Open Multiplayer 15 Jan 3, 2022
The C++ Network Library Project -- cross-platform, standards compliant networking library.

C++ Network Library Modern C++ network programming libraries. Join us on Slack: http://slack.cpp-netlib.org/ Subscribe to the mailing list: https://gr

C++ Network Library 1.9k Jun 10, 2022
Small and fast cross-platform networking library, with support for messaging, IPv6, HTTP, SSL and WebSocket.

frnetlib Frnetlib, is a cross-platform, small and fast networking library written in C++. There are no library dependencies (unless you want to use SS

Fred Nicolson 22 May 16, 2022
C++ Parallel Computing and Asynchronous Networking Engine

As Sogou`s C++ server engine, Sogou C++ Workflow supports almost all back-end C++ online services of Sogou, including all search services, cloud input method,online advertisements, etc., handling more than 10 billion requests every day

Sogou Open Source 8.4k Jun 24, 2022
Portable, single-file, protocol-agnostic TCP and UDP socket wrapper, primarily for game networking

Documentation This is a header-only library, as such most of its functional documentation is contained within the "header section" of the source code

null 62 Mar 23, 2022
Asynchronous networking for C

Overview Dyad.c is an asynchronous networking library which aims to be lightweight, portable and easy to use. It can be used both to create small stan

null 1.3k Jun 23, 2022
ENet reliable UDP networking library

Please visit the ENet homepage at http://enet.bespin.org for installation and usage instructions. If you obtained this package from github, the quick

Lee Salzman 2.1k Jun 24, 2022
canonical libwebsockets.org networking library

Libwebsockets Libwebsockets is a simple-to-use, MIT-license, pure C library providing client and server for http/1, http/2, websockets, MQTT and other

lws-team 3.5k Jun 25, 2022
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Cesanta Software 8.5k Jun 29, 2022
Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption.

GameNetworkingSockets GameNetworkingSockets is a basic transport layer for games. The features are: Connection-oriented API (like TCP) ... but message

Valve Software 6.1k Jun 21, 2022
High-level networking API for real-time simulations with primitives for remote procedure call and object state replication

tnl2 - Torque Network Library version 2 tnl2 is a high-level networking API for real-time simulations with primitives for remote procedure call and o

Mark Frohnmayer 23 Apr 10, 2022
Backroll is a pure Rust implementation of GGPO rollback networking library.

backroll-rs Backroll is a pure Rust implementation of GGPO rollback networking library. Development Status This is still in an early beta stage. At ti

Hourai Teahouse 223 Jun 20, 2022
requests-like networking library using boost for C++

cq == C++ Requests cq == C++ Requests is a "Python Requests"-like C++ header-only library for sending HTTP requests. The library is inspired a lot by

null 11 Dec 15, 2021
The Beginner's Guide to eBPF Programming for Networking

The Beginner's Guide to eBPF Programming for Networking As seen at Cloud Native eBPF Day 2021. Setup Create a container that we can issue curl request

Liz Rice 66 Jun 21, 2022
C++ networking library including UniConf and a convenient D-Bus API

This is wvstreams, a nominally platform-independent networking and utilities library for C++. Some documentation is in the Docs/ directory. If that

null 27 Dec 29, 2021
Socket and Networking Library using msgpack.org[C++11]

netLink C++ 11 KISS principle networking library. Features: C++ 11 IPv4, IPv6 Protocols: TCP, UDP Enable/Disable blocking mode Join/Leave UDP-Multicas

Alexander Meißner 208 May 29, 2022
Simple and small reliable UDP networking library for games

libquicknet Simple and small reliable UDP networking library for games ❗ libquicknet is under development and not suitable for production code ❗ The m

null 23 May 12, 2022
Data-oriented networking playground for the reliable UDP transports

NetDynamics is a data-oriented networking playground for the reliable UDP transports. The application was created for stress testing and debugging a p

Stanislav Denisov 88 Jun 20, 2022