Core: WebSocket Connect in blocking mode issue fixed

git-svn-id: svn://ultimatepp.org/upp/trunk@11468 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-11-15 07:38:07 +00:00
parent f77eb146e0
commit c736712eba
3 changed files with 11 additions and 6 deletions

View file

@ -680,7 +680,7 @@ public:
String GetError() const { return Nvl(socket->GetErrorDesc(), error); }
bool Accept(TcpSocket& listener_socket);
void Connect(const String& url);
bool Connect(const String& url);
void Do();

View file

@ -54,7 +54,7 @@ bool WebSocket::Accept(TcpSocket& listen_socket)
return true;
}
void WebSocket::Connect(const String& url)
bool WebSocket::Connect(const String& url)
{
Clear();
@ -80,15 +80,19 @@ void WebSocket::Connect(const String& url)
if(socket->IsBlocking()) {
if(!addrinfo.Execute(host, port)) {
Error("Not found");
return;
return false;
}
LLOG("DNS resolved");
StartConnect();
while(opcode != READING_FRAME_HEADER)
while(opcode != READING_FRAME_HEADER) {
Do0();
if(IsError())
return false;
}
}
else
opcode = DNS;
return true;
}
void WebSocket::SendRequest()

View file

@ -45,9 +45,10 @@ cpSocket][@(0.0.255) `&]_[*@3 listen`_socket])&]
on success.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:WebSocket`:`:Connect`(const Upp`:`:String`&`): [@(0.0.255) void]_[* Connect](
[s5;:Upp`:`:WebSocket`:`:Connect`(const Upp`:`:String`&`): [@(0.0.255) bool]_[* Connect](
[@(0.0.255) const]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 url])&]
[s2;%% Initiates connection to [%-*@3 url].&]
[s2;%% Initiates connection to [%-*@3 url]. In blocking mode returns
false if connection cannot be established, otherwise true.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:WebSocket`:`:Do`(`): [@(0.0.255) void]_[* Do]()&]