PHP Classes

PHP UDP Hole Punching: Connect to network peers through a UDP server

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 287 All time: 7,533 This week: 673Up
Version License PHP version Categories
php-hole-puncing 1.0.0Artistic License5Networking, PHP 5, P2P
Description 

Author

This package can be used to connect to network peers through a UDP server.

There is a client class that sends UDP packets to a server listening to a given port on a given IP address to request the list of other network clients that connected to the server.

The server class returns the list of IP addresses and ports of connected clients and sends another UDP message to IP address and port of each client.

The server also keeps sending ping packets to determine if each client is still connected.

Innovation Award
PHP Programming Innovation award nominee
August 2016
Number 7


Prize: One ebook of choice by Packt
When you want to connect to a remote machine that is connected to a group of peers but you do not know its address, one common solution is to connect to central server and ask the addresses of the peers to communicate with them.

This technique is used by NAT servers (Network Address Translators) that are often running on router machines in order to route requests to remote machines from local network computers.

This process is called hole punching because it uses an intermediary server to get the addresses of the remote machines, so the client can communicate with them.

This PHP package implements a server with one class that can keeps the list of connected client machines and returns the list of peer addresses and ports.

The client class connects to the server class to get the peer machine address list, so it can send messages to them using UDP packets.

Manuel Lemos
Picture of Nick Daniels
  Performance   Level  
Name: Nick Daniels <contact>
Classes: 13 packages by
Country: United States United States
Age: 34
All time rank: 1107160 in United States United States
Week rank: 15 Up3 in United States United States Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php

require 'cloud.class.php';

$cloud = new udpHolePuncherCloud();
$cloud->init();


  Files folder image Files (4)  
File Role Description
Plain text file client.class.php Class Client Class
Accessible without login Plain text file client.example.php Example Client Example
Plain text file cloud.class.php Class Cloud/Server Class
Accessible without login Plain text file cloud.example.php Example Cloud/Server Example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:287
This week:0
All time:7,533
This week:673Up