File: README.md

package info (click to toggle)
ulfius 2.7.15-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,856 kB
  • sloc: ansic: 23,025; makefile: 708; sh: 140
file content (69 lines) | stat: -rw-r--r-- 1,657 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# websocket_server

Run a webservice service or client.

## Compile and run

### HTTP mode

Run a HTTP (non secure) webservice

```bash
$ make debug
$ LD_LIBRARY_PATH=../../src: ./websocket_server
```

### HTTPS mode

You must have a certificate key and pem files available. To generate one, you can for example use the following command:

```bash
$ openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.key -sha256
```

Run a HTTPS (secure) webservice

```bash
$ make debug
$ LD_LIBRARY_PATH=../../src: ./websocket_server -https cert.key cert.pem
```

## Endpoints available:

### Websocket

- `GET http://localhost:9275/websocket`: Websocket basic endpoint that will send binary or text messages every 2 seconds
- `GET http://localhost:9275/websocket/file`: Websocket endpoint that will accept a binary message that can contain a file
- `GET http://localhost:9275/websocket/echo`: Websocket echo endpoint, all received messages will be resend to the client

### Static file

- `GET http://localhost:9275/static`: will serve the files located in the `static` folder

## Test the websocket

### Browser

Open in your browser the url [http[s]://localhost:9275/static/index.html](http://localhost:9275/static/index.html), this will open an HTML page where you can test the websockets behaviour.

### Ulfius client

Run the `websocket_client` program while the `websocket_server` is running.

### HTTP mode

Run a HTTP (non secure) webservice

```bash
$ make debug
$ LD_LIBRARY_PATH=../../src: ./websocket_client
```

### HTTPS mode

Run a HTTPS (secure) webservice

```bash
$ make debug
$ LD_LIBRARY_PATH=../../src: ./websocket_client -https
```