https://github.com/flowerwrong/cwebsocket
A websocket server in c
https://github.com/flowerwrong/cwebsocket
Last synced: 3 months ago
JSON representation
A websocket server in c
- Host: GitHub
- URL: https://github.com/flowerwrong/cwebsocket
- Owner: FlowerWrong
- Created: 2015-12-02T03:51:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-05T05:29:35.000Z (over 9 years ago)
- Last Synced: 2025-01-11T11:16:09.370Z (5 months ago)
- Language: C
- Size: 1010 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## A websocket server in c
#### Install
```bash
make
```#### Usage
* -D: run server in daemonize.
```bash
make s # or make sd
```#### Curl
```bash
curl -i -X GET http://127.0.0.1:5001
curl -i -X POST http://127.0.0.1:5001 -d "name=yang"
curl -i -X DELETE http://127.0.0.1:5001/1
curl -i -X PUT http://127.0.0.1:5001 -d "name=yang"
curl -i -X PATCH http://127.0.0.1:5001 -d "name=yang"
```#### Gcc
* -L/usr/local/lib: 表示要链接的库在此目录下
* -ltest: 编译器查找动态连接库时有隐含的命名规则,即在给出的名字前面加上lib,后面加上.so来确定库的名称
* ldd server
* `ldconfig -p | grep webso`: search shared library
* [shared library not found issue](https://github.com/payden/libwebsock/issues/22)#### Benchmark
```bash
ab -n1000 -c10 http://localhost:5001/
netstat -anl | grep "5001"
lsof -i:5001
```#### Reference
* [rfc6455](https://tools.ietf.org/html/rfc6455)
* [rfc6455 in Chinese](https://www.gitbook.com/book/chenjianlong/rfc-6455-websocket-protocol-in-chinese/details)
* [mozilla: Writing_WebSocket_servers](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers)
* [zlog](https://github.com/HardySimpson/zlog)
* [http-parser](https://github.com/nodejs/http-parser)
* [tinyhttp](https://github.com/mendsley/tinyhttp)
* [h3](https://github.com/c9s/h3)
* [picohttpparser](https://github.com/h2o/picohttpparser)