
# WebSocket relay server

### Creates communication channels between web clients

#### Description
Allows multiple clients, usually web clients or devices beihind NAT with no
direct connectivity with each other to exchange messages. Supported protocols:
RAW TCP, TLS, WebSocket and secure WebSocket. Secure connections require a
certificate file in the current directory with the name `gvalkov.com.pem`.
The server automatically uses the protocol requested by the client, and falls
back to RAW if no protocol is detected. Port 81 is used by default, see
`G_SOCKET::config` in [g_socket.cpp](src/g_socket.cpp).
[Cube3D_devicemotion](https://gvalkov.com/MSDN/Cube3D_devicemotion.htm) can be
used as a sample client, where one device shares its accelerometer data with
another. Browsers should display rotating cube.

#### Command line options
```text
g_relay <-p listen port><-c connections><-L packet length>
```

| Command | Alternative  | Description |
| ------: | :----------- | :---------- |
| `-h`    |              | Help        |
| `-p`    |              | Listen port |
| `-c`    | `1-32`       | Number of connections |
| `-L`    |              | Packet length e.g. `1472` `1405` `1422` `65112` `65507` |


#### Video demo [Accelerometer 3D cube + WebSocket relay](https://youtu.be/iXXiZTyNA8E)
[![Accelerometer 3D cube + WebSocket relay](http://img.youtube.com/vi/iXXiZTyNA8E/0.jpg)](https://youtu.be/iXXiZTyNA8E)

#### Supported Platforms
☂︎ Apple iOS, macOS  
☂︎ FreeBSD  
☂︎ Linux, OpenWRT  
☂︎ Windows  


#### [Prerequisites and build instructions](../../../lib.git#Prerequisites)


#### © 2014-2023 Georgi Valkov
https://httpstorm.com/download/g_relay/
