RMNP aims to combine all the advantages of TCP and the speed of UDP in order to be fast enough to support modern realtime games like first person shooters. It is basically an extension for UDP.
The bad thing about TCP is that once a packet is dropped it stops sending all other packets until the missing one is delivered. This can be a huge problem for games that are time sensitive because it is not uncommon for devices to encounter packet-loss. Therefore RMNP facilitates UDP to guarantee fast delivery without any restrictions. Because UDP is stateless RMNP implements an easy way to handle connection and to distinguish between "connected" clients. Every packet contains a small header mainly containing a CRC32 hash to ensure that all received packets were transmitted correctly.
To guarantee reliability the receiver sends acknowledgment packets back to tell the sender which packets it received. The sender resends each packet until it received an acknowledgment or the maximum timeout is reached. Because of that RMNP is not 100% reliable but it can be assumed that a packet will be delivered unless a client has a packet-loss of about 100% for a couple seconds.
go get github.com/obsilp/rmnp
Example Pong Server
package main
import "github.com/obsilp/rmnp"
func main() {
server := rmnp.NewServer(":10001")
server.Start() // non-blocking
// other code ...
}
Example Ping Client
package main
import "github.com/obsilp/rmnp"
func main() {
client := rmnp.NewClient("127.0.0.1:10001")
client.Connect() // non-blocking
// other code ...
}
Events and received packets can be received by setting callbacks. Look at the respective classes for more information.
Client callbacks | Server callbacks
This project is licensed under the MIT License - see the LICENSE file for details