davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.01k stars 250 forks source link

Onion examples - websockets: close websocket? #268

Open alexe100 opened 4 years ago

alexe100 commented 4 years ago

Hi I am trying onions' websocket example using the "Simple Websocket Client" firefox extension as client. It works. It can connect, send information but when I close connection on client side some seconds later I see this on server:

"GET /" 101 0 (Keep-Alive) [ERROR websockets.c:68] Error reading data: 9: Bad file descriptor (255)

If we test the contents of the data_ready_len argument we realize that it has value -1. Hence, -1 means websocket closed, right?

In that case we should close the socket on server side, right?

How to close the socket that is passed by argument? close() does not work.

onion_connection_status websocket_example_cont(void data, onion_websocket ws, ssize_t data_ready_len) { ... }

Thanks a lot