Jenkins Software

FAQ

What is the difference between the license versions?

Indy License
RakNet is free up to 250K gross. After that, you'd be obligated to purchase a single application license. Until such time, you must display the RakNet logo in your splash screen or credits. Lastly, it can only be distributed as a downloadable game (not retail) for the PC, Mac, or Linux. If you plan to make more than 250K, you can use the free license until your sales build up to where you do.

Single application license:
A Single Application license applies to commercial software sold both online and retail. You may download RakNet immediately and are only required to pay when you ship your product. At that time you choose how much to pay based on what you can afford and how much value you feel RakNet has brought to you.

Site licenses and commercial engine development.
An unlimited application Engine License applies to commercial software sold using any distribution model and also allows resale of your engine. You may use RakNet as long as you wish during development. When you wish to sell your engine or release your product, you may purchase a license at a fixed fee.

All licenses can support any number of players.

I'm having problems sending strings.
Use the StringCompressor class to send strings.

My data that I write using bitstreams is messed up on the other side.
Make sure if you write one of the ID_* enumerations you cast it to an (unsigned char). Other than that, make sure your read and write calls match.

My data pointed to by a pointer isn't arriving.
This is the same problem as when trying to use a default copy constructor with allocated memory. You can just send pointers if you want, but it will send the pointer variable rather than the data pointed to. You will need to serialize the contents of pointers yourself.

I get very high pings.
Use 0 for the sleep timer, and put a Sleep(0) in your main game loop. This will ensure responsive context switches.

I get very high CPU usage
Use 30 for the sleep timer. This will ensure RakNet spends most of its time waiting.

How should I deal with firewalls?
Be sure to specify that your end-users need to open the appropriate ports, or use a port that is probably already open (such as the http port). One way to reduce tech support calls in this regard is to have your application try connecting a local client to a local server. If you can't connect after a couple of tries then the user probably has a firewall blocking this. You can message the user in-game that they probably have a firewall that needs to be turned off on whichever port your game uses.

I get linker errors such as: unresolved external symbol "public: static void __cdecl RakNetworkFactory::DestroyRakPeerInterface(class RakPeerInterface *)"
You didn't link the library into your project. You must have the .lib and not the .dll in the project. See Compiler Setup

I get conflicting lib errors such as follows
LIBCMT.lib(dosmap.obj) : error LNK2005: __dosmaperr already defined in LIBCD.lib(dosmap.obj)
LIBCMT.lib(mbctype.obj) : error LNK2005: __getmbcp already defined in LIBCD.lib(mbctype.obj)
LIBCMT.lib(mbctype.obj) : error LNK2005: __setmbcp already defined in LIBCD.lib(mbctype.obj)
LIBCMT.lib(mbctype.obj) : error LNK2005: ___initmbctable already defined in LIBCD.lib(mbctype.obj)
LIBCMT.lib(tolower.obj) : error LNK2005: __tolower already defined in LIBCD.lib(tolower.obj)
LIBCMT.lib(tolower.obj) : error LNK2005: _tolower already defined in LIBCD.lib(tolower.obj)
LIBCMT.lib(isctype.obj) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

You need to select Multithreaded Debug and Multithreaded libraries in the project options.

I get linker errors such as follows
LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in MSVCRTD.lib(MSVCR80D.dll)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library

Right click on the project name, click properties, go to Configuration Properties / C/C++ / Code Generation and change from Multithreaded Debug DLL to Multithreaded Debug (same for release).

Dropped connections are not detected and/or I can't reconnect after losing the connection.
By default, the timeout in debug build is set to 30 seconds, and in release to 10 senconds. A detect lost connections message is sent every 5 seconds. So you may have to wait 35 seconds before you can reconnect. You can change the timeout using RakPeerInterface::SetTimeoutTime.

I want to, or should I call Send and Receive from multiple threads.
Those functions are not threadsafe. There is no benefit to calling them from threads, as they are already optimized to run asynchronously with the main network thread. Use RAKNET_THREADSAFE in RakNetDefines.h if you insist on doing this.

I want event callbacks on packet arrival.
There are no event callbacks on packet arrival. If you want an event, poll Receive and make your own event if non-zero is returned.

I can't connect to the other system or other systems can't connect to me. What are some possible reasons?

  • The other system isn't running RakNet.
  • The other system didn't start the connection, or tried to start it and it failed (the startup function returned false).
  • The server has a firewall blocking incoming connections.
  • The server has a firewall blocking UDP data on the specified server port or the server port + 1 (for winsock 2.0+).
  • The client has a firewall blocking UDP data on the specified client port or the server port + 1 (for winsock 2.0+).
  • The server already has the maximum number of connected clients.
  • The server has a lot of network traffic and is too busy to respond to your connection request.
  • You used a different value for connectionValidationInteger than the other system.
  • You are connecting to the wrong port on the server.
  • You entered the wrong IP address of the server. This could be by mistyping or confusing the LAN address with the internet address.
  • One or both systems are not using high priority threads and are at the same time using a lot of CPU power for other threads. This could cause the network threads to not respond to the handshaking sequence fast enough.
  • The handshaking packets were lost due to normal packetloss
  • You did connect, but never handled the network messaging packets that indicated you you did either because you aren't handling any messages or because you didn't handle those in particular.
  • The recipient is behind a NAT and didn't use NAT punch-through.
I get linker errors about winsock function redefinitions
i.e. - error C2011: 'WSAData' : 'struct' type redefinition
i.e. - warning C4005: 'SO_DONTLINGER' : macro redefinition


Add this to your preprocessor definitions
_WINSOCKAPI_
In .Net this would be project / configuration properties / C/C++ / Preprocessor / Preprocessor defintions.
You will get this or a similar warning:
warning C4005: '_WINSOCKAPI_' : macro redefinition unknown(0) : see previous definition of '_WINSOCKAPI_'
You can ignore it.

I can connect but don't get any data from the other system. What are some possible reasons?

You aren't calling Receive.
The other system didn't send any data, or didn't send any to you.
The other system immediately kicked you after you connected, such as due to you being banned or using a wrong password.
The network disconnected you because of cheating or because it couldn't deliver a reliable packet.

Some kind of networked action happens twice, such as when I press the trigger to fire a bullet two bullets come out.

The server is broadcasting to everyone, including the client that just initiated the action. To fix this, pass the systemAddress parameter of the packet to the systemAddress field of RakPeerInterface::Send when broadcasting. This will relay the message to all players BUT the sender.

When I send some particular kind of packet, I immediately get flooded with hundreds of copies the same packet.
This is a feedback loop, caused by the following sort of coding:

// Client
void DoMyFunctionA(void)
{
SendPacketToDoFunctionA();
}

// Server
void HandlePacketToDoFunctionA(void)
{
// Broadcast to all connected players
SendToAllPacketToDoFunctionA();
}

// Client
void ReceivePacketToDoFunctionA(void)
{
DoMyFunctionA();
}

To fix this, either don't have the function that does the action also send the packet, or use a parameter specifying whether to send a packet or not and set that parameter to false if the function is called from the network code. See Programming Tips for help on how to handle this.

How do I create a master game browser?
Use the LightweightDatabaseServer and LightweightDatabaseClient classes. See the sample \Samples\LightweightDatabase

Which version of the multithreaded library does RakNet use?
Multithreaded (/MT)

Since RakNet uses threads does my program need to use the multithreaded library?
If you use the DLL then no. The threads are confined to the dll. If you use the static lib or source then yes.

Can I run more than one instance of the client or server on the same system?
Yes, but each instance will have its own thread and require its own memory. You'll need to remember to give different port assigments to each instance as well. There isn't really any reason to do this since you can use RakPeer to handle multiple outgoing connections.

What's the largest packet I can send?
65535 * (the MTU Size - the UDP / IP header). For a cable modem this is about 95 megabytes. Of course you wouldn't be able to send anything else above the MTU until that arrived. You can use RakNet for small files but for major file transfers you might as well TCP, which is designed for that.

How do I send files?
Just send it as a data stream using RELIABLE, subject to the packet size restriction.

If I purchase one license, can I use it in more than one game?
A site license will allow you to do this. A normal license requires one copy of the license per game. Refer to the License Agreement for full details.

Can I use RakNet in non-games?
Yes

My game is too laggy. How can I decrease lag?
- Use bandwidth more efficiently (see the optimization section in Programming Tips )
- Design your game so it doesn't require as much bandwidth (see the optimization section in Programming Tips )
- Use high priority threads
- Get a faster computer. This will make threads more responsive.
- Get a better internet connection.
- Decrease the number of clients allowed.

Does RakNet use TCP at all?
RakPeer does not. However, some plugins support it - EmailSender, Autopatcher, FileListTransfer, DeltaDirectoryTransfer.

Will RakNet work with my game written in C?
No.
See Also
Index