I've been playing around with your websockets implementation and I found that, at least with my setup, the socket connections were not being cleaned up after a closed connection. For instance, if I hit refresh, browse away, etc, and then try to create a new socket, Chrome would throw an error saying "invalid status line" or something of that sort.
I traced it down to the end of the cgiWebsocket() method in cgiwebsocket.c:
//Sending is done. Call the sent callback if we have one.
Websock *ws=(Websock*)connData->cgiPrivData;
if (ws && ws->sentCb) ws->sentCb(ws);
if (ws && ws->priv->mustClose) return HTTPD_CGI_DONE;
return HTTPD_CGI_MORE;
After 1 or 2 connections it forever returns HTTPD_CGI_DONE, but never gets to the cleanup code on a terminated connection.
I tweaked it to close the connection and then let it continue to HTTPD_CGI_MORE and then on the next go-around it detects the null connection and cleans up. Like so:
I could be doing something fundamentally wrong here as I'm not too familiar with websockets, but my static html page creates the WS on a button click, so I'm pretty sure I'm not generating multiple.
I've been playing around with your websockets implementation and I found that, at least with my setup, the socket connections were not being cleaned up after a closed connection. For instance, if I hit refresh, browse away, etc, and then try to create a new socket, Chrome would throw an error saying "invalid status line" or something of that sort.
I traced it down to the end of the cgiWebsocket() method in cgiwebsocket.c:
After 1 or 2 connections it forever returns HTTPD_CGI_DONE, but never gets to the cleanup code on a terminated connection.
I tweaked it to close the connection and then let it continue to HTTPD_CGI_MORE and then on the next go-around it detects the null connection and cleans up. Like so:
After doing this it seems to work just fine.
I could be doing something fundamentally wrong here as I'm not too familiar with websockets, but my static html page creates the WS on a button click, so I'm pretty sure I'm not generating multiple.