U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Problem with websocket connect method
Re: Problem with websocket connect method [message #48974 is a reply to message #48954] Wed, 15 November 2017 08:40 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
shutalker wrote on Fri, 10 November 2017 07:05
I've got a problem with websocket connect method. When a server drops connection, a client is still waiting for something. So if I do blocking connect, my app execution will be blocked.
Here what I've found in source WebSocket.cpp:

...

if(socket->IsBlocking()) {

...

    StartConnect();
    while(opcode != READING_FRAME_HEADER)
        Do0();
}

...



As I can understand, in blocking mode connect will never leave while cycle until it will read response header from server. And there is no check whether the socket was closed or an error was happened

I use upp sources from git: 97e1f20
Compiler: GCC 5.4.0


You are right. Hopefully fixed (in trunk):

	if(socket->IsBlocking()) {
		if(!addrinfo.Execute(host, port)) {
			Error("Not found");
			return false;
		}
		LLOG("DNS resolved");
		StartConnect();
		while(opcode != READING_FRAME_HEADER) {
			Do0();
			if(IsError())
				return false;
		}
	}


As you can see, I have also added return value for blocking mode...

Mirek
 
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: Bug with FindMatch(const Range& r, const C& match, int from = 0)
Next Topic: Vector<Vector<double>>
Goto Forum:
  


Current Time: Wed Sep 23 13:48:06 GMT+2 2026

Total time taken to generate the page: 0.06446 seconds