Keywords:Networking, Libraries & Frameworks & Tools & Documents Notes

Networking Layer

Cross-platform asynchronous I/O

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





Rollback - Input Prediction

Good Game, Peace Out Rollback Network SDK

Reliable UDP

KCP - A Fast and Reliable ARQ Protocol

Lite reliable UDP library for Mono and .NET

ENet reliable UDP networking library


A rule-based tunnel in Go.


A UDP to TCP proxy server for sending HTTP requests with zero roundtrips.

Web Server

Mongoose Embedded Web Server Library - Mongoose is more than an embedded webserver. It is a multi-protocol embedded networking library with functions including TCP, HTTP client and server, WebSocket client and server, MQTT client and broker and much more.


WebRTC is a free, open software project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.

webrtc source code from chromium.

A reference gradle project that let you explore WebRTC Android in Android Studio.

Open WebRTC Toolkit (OWT) is an end to end audio/video communication development toolkit based on WebRTC, which is used to create high-performance, reliable, and scalable real-time communication solutions.

Web-based Cloud Gaming service for Retro Game

libwebrtc binaries ( Recommended )

WebRTC Build Tool for iOS/Android ( Recommended )

Google’s WebRTC implementation in a single static library.I changed some things, make it could build M70 webrtc with h264.( Recommended )

Update WebRTC version to m72. ( Recommended )

WebRTC dynamic library wrapper for flutter desktop plugin.

Google’s WebRTC implementation in a single static library.

Janus WebRTC Server ( Recommended )

Amazon Kinesis Video Streams Webrtc SDK is for developers to install and customize realtime communication between devices and enable secure streaming of video, audio to Kinesis Video Streams.


TCP Examples

How to Code a Server and Client in C with Sockets on Linux – Code Examples

[分享] Windows Socket 速查筆記

How do I change a TCP socket to be non-blocking?

Linux socket example:

bool InitSocket()
	int server_sockfd = socket(AF_INET, SOCK_STREAM, 0);

	//set non blocking mode
	int flags  = fcntl(server_sockfd, F_GETFL, 0);
	if(fcntl(server_sockfd, F_SETFL, flags | O_NONBLOCK) != 0)
        return false;

	oAddr.sin_family = AF_INET;
	oAddr.sin_addr.s_addr = INADDR_ANY;
	oAddr.sin_port = htons((u_short)6666);
	if (bind(server_sockfd,(sockaddr*)&oAddr, sizeof(oAddr)) != 0)
        return false;
	const int MAX_CONNECTION = 100;
	if (listen(server_sockfd, MAX_CONNECTION) != 0)
        return false;
	return true;

void recv_thread()
        int client_sockfd = accept(....);
        int flags = fcntl(client_sockfd, F_GETFL, 0);
        fcntl(client_sockfd, F_SETFL, flags | O_NONBLOCK);	//!!! don't use `if(fcntl(...) != 0)`;

How to give a specific ip address to server and client?
Server side:

// Error checking omitted for expository purposes
int sockfd = socket(AF_INET, SOCK_STREAM, 0);

// Bind to a specific network interface (and optionally a specific local port)
struct sockaddr_in localaddr;
localaddr.sin_family = AF_INET;
localaddr.sin_addr.s_addr = inet_addr("");
localaddr.sin_port = 0;  // Any local port will do
bind(sockfd, (struct sockaddr *)&localaddr, sizeof(localaddr));

Client side:

// Connect to the remote server
struct sockaddr_in remoteaddr;
remoteaddr.sin_family = AF_INET;
remoteaddr.sin_addr.s_addr = inet_addr(server_ip);
remoteaddr.sin_port = htons(server_port);
connect(sockfd, (struct sockaddr *)&remoteaddr, sizeof(remoteaddr));


Detecting TCP Client Disconnect

In TCP there is only one way to detect an orderly disconnect, and that is by getting zero as a return value from read()/recv()/recvXXX() when reading.

There is also only one reliable way to detect a broken connection: by writing to it. After enough writes to a broken connection, TCP will have done enough retries and timeouts to know that it's broken and will eventually cause write()/send()/sendXXX() to return -1 with an errno/WSAGetLastError() value of ECONNRESET, or in some cases 'connection timed out'. Note that the latter is different from 'connect timeout', which can occur in the connect phase.



WebSocket Issues: error on reading from skt : 10054

Error code on server:

error on reading from skt : 10054

Caused by:
Client disconnected from server.


WebSocket vs. TCP

WebSockets performs quite well, with an average round trip time of about 20 microseconds (0.02 milliseconds), but straight up TCP still beats it handily, with an average round trip time of about 2 microseconds (0.002 milliseconds), an order of magnitude less.

WebSockets vs. Regular Sockets


TCP Block

BBR, the new kid on the TCP block

TCP 拥塞避免算法


Online Gaming

Online Gaming Explained: Why Netcode Goes Wrong + How To Improve Performance [Sponsored]

Is man merely a mistake of God's? Or God merely a mistake of man? ― Friedrich Nietzsche