FAQ

What is the difference between the license versions?
The freeware license is GPL.
The shareware license can only be sold, resold, or distributed electronically.
The commercial license can be distributed normally.
All licenses can support any number of players.
I get spikes OR I get very high pings, even to the local system
Use 0 for the sleep timer, and put a Sleep(0) in your main game loop. This will ensure responsive context switches.
I get error LNK2001: unresolved external symbol ___security_cookie
MSVC .net puts this in libs and dlls by default and it is not supported in MSVC 6. You'll have to rebuild the lib using your own compiler.
I hit an assert packetsReleased==0.
This is the packet pool reporting that all packets allocated were not released. This will sometimes hit on shutdown if you rely on the destructor to shutdown RakNet and/or don't call RakNetworkFactory::DestroyRak*Interface. It is due to the order of the destructor calls for global objects. You can ignore it or comment it out in that case. If it happens every time, then you really are not returning allocated packets to the pool via DeallocatePacket
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 ClientServerFactory::DestroyRakClientInterface(class RakClientInterface *)"
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 about the bitstream class
Sometimes the DLL won't link in the bitstream class. Include Bitstream.h and Bitstream.cpp in your project.
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.
When ever I define __USE_IO_COMPLETION_PORTS I get a huge number of errors.
All of them are of the type:
winsock2.h(2353) : error C2375: 'WSAAsyncSelect' : redefinition; different linkage
winsock.h(824) : see declaration of 'WSAAsyncSelect'
One for each of the functions exported by winsock2.
Windows.h has to be included after the Rak* headers. __USE_IO_COMPLETION_PORTS has to be defined globally, or before the headers.
Object are never replicated on remote systems when using the DistributedNetworkObject class.
You forgot to call DistributedNetworkObjectManager::Instance()->RegisterRakServerInterface(rakServer); and/or the version for the client.
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 playerId parameter of the packet to the playerId field of Server::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 MasterServer and MasterClient classes provided in Sample Applications
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 (except for IO completion ports, which share threads) 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.
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?
No.
Will RakNet work with my game written in C?
Not unless you are willing to use C++ interfaces.
What OSes does RakNet support?
Unix, Linux, and Windows. It sort-of supports Mac too :)

See Also

Index