Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Example for ENet on how to connect 2 peers to each other that are both behind a NAT using NAT hole punching.

Notifications You must be signed in to change notification settings

codecat/enet-p2p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

ENet P2P example

This is an example for ENet that lets you connect 2 peers to each other that are both behind a NAT, using NAT hole punching and an intermediate server.

The source

The source is merely an example, so I don't provide any means to build it. Although it should build and run okay, given you change ServerHostName in the client file to point to your own server.

How it works

  1. The server needs to be running on some publicly available (non-NAT) server.
  2. Each client connects to the server via enet_host_connect.
  3. Server sends full peer addresses of all connected peers to all other peers.
  4. Each peer connects directly using enet_host_connect to the same address reported by the server.
  5. Once 2 peers both connect to each other, the connection will be established and you may start sending packets!

About

Example for ENet on how to connect 2 peers to each other that are both behind a NAT using NAT hole punching.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages