Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to close the websocket connection
Re: How to close the websocket connection [message #49487 is a reply to message #49459] Sat, 17 February 2018 12:01 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
uppjj wrote on Wed, 14 February 2018 19:17
Hello
I got the same problem, "Close" put my websocket client in infinite loop.
Server receives the "Close" message from the client but does not actually send the response, because it is in non-blocking mode.
I just do this change in uppsrc/core/WebSocket.cpp , function "out":

// while(IsBlocking()  && socket->IsOpen() && !IsError() && out_queue.GetCount())
   while((IsBlocking() || (s[0] == CLOSE))  && socket->IsOpen() && !IsError() && out_queue.GetCount())


and got "Close" working well...


Thanks. I believe this has a problem of occassionally turning nonblocking socket into blocking, as Out is used for data too.

I suggest this:


void WebSocket::Out(const String& s)
{
	out_queue.AddTail(s);
	while((IsBlocking() || close_sent) && socket->IsOpen() && !IsError() && out_queue.GetCount())
		Output();
}



Would that work for you?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Vector<Vector<double>>
Next Topic: how to convert unicode to String
Goto Forum:
  


Current Time: Tue May 07 00:47:13 CEST 2024

Total time taken to generate the page: 0.03272 seconds