• Examples (iOS)
• Examples (Java/Android)
• Examples (C++)
Server API Documentation


» The SmartFoxServer 2X protocol

SmartFoxServer 2X employs an efficient binary protocol with support for LZW compression and TSL 1.2 encryption. A lightweight protocol codec allows the server to process tens of thousands of packets even on a low spec machine, such as an old Intel Core Duo cpu, allowing lightning fast performance on modern, multi-cpu hardware.

The protocol can be transmitted via a number of transports such as:

» Clients and transport types

Depending on the client platform in use we support a variety of different transports. The table below recapitulates the options available for every supported client technology:

Transport type


TCP socket UDP socket HTTP tunnel Websocket
Unity WebGL build      
Other builds  
iOS / macOS / tvOS  
Android / Java2 SE  
Flash Web Player    
Adobe Air publishing  
Windows Universal  

» TCP and UDP socket

This is the default and recommended modality for most client platforms such as Unity, Java/Android, iOS, Flash, etc. The client establishes a direct TCP connection to the server (default port = 9933) that lasts for the entire game session. Additionally the application can also send data via UDP for faster response times.

From the SFS2X Administration Tool, under the Server Configurator > General tab, it is possible to add any number of TCP and UDP listeners in the server.

» HTTP Tunnel (BlueBox)

The HTTP Tunnel solution offered by SmartFoxServer 2X is called BlueBox and it is a failover technology for clients unable to use TCP sockets. The client API can automatically revert to an HTTP-based connection that acts as a tunnel for the standard SFS2X protocol (including TLS encryption).

This way players behind a firewall or proxy can still enjoy online multiplayer games at a moderate performance cost. Even most real-time games should remain playable in this context since the BlueBox offers a series of optimizations to compensate the added latency of the HTTP-based solution.

The BlueBox requires the internal web server to be active and properly configured in the Administration Tool's Server Configurator > Web Server tab.

To learn more about the BlueBox, we recommend this article.

» Websocket

WebSocket is the W3C standard for socket communication in native HTML5 applications written in JavaScript. In conjunction with the latest web-browser technologies such as Canvas and WebGL, this opens interesting opportunities to create sophisticated online games and applications based on low-latency persistent connections that don't require any browser plug-in.

SmartFoxServer 2X provides full support for websockets in both standard (WS) and secure form (WSS) via the internal web server, which is tightly integrated with SFS2X engine.

From the SFS2X Administration Tool, under the Server Configurator > Web Server tab, it is possible to activate each service, configure the respective ports and switch between two different sub-protocols: text (for legacy JavaScript clients) and binary (since SmartFoxServer 2X 2.13.0).