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 #49574 is a reply to message #48944] Sun, 04 March 2018 15:51 Go to previous message
uppjj is currently offline  uppjj
Messages: 9
Registered: February 2018
Location: France
Promising Member
Ok thanks. This is working now with your new code, with url containing subfolder or not :

// adress
String Host,SubFolder;
bool ssl;
Adress_Split(Url,Host,SubFolder,ssl);
// header
WS_Client.ClearHeaders().Header("Upgrade","websocket").Header( "Connection","Upgrade").Header("Sec-WebSocket-Version", "13"); // may be standard part of header ?
WS_Client.Header("Sec-WebSocket-Protocol","your_protocol")...; // custom part
// connect
WS_Client.Connect(SubFolder,Host,ssl); // ok working now !
...

with :

void Adress_Split(const String& url,String& host,String& Subfolder,bool& ssl)
{// copy of the beginning of connect(url)
Subfolder = url;
const char *u = url;
ssl = memcmp(u, "wss", 3) == 0;

//--- Host
const char *t = u;
while(*t && *t != '?')
if(*t++ == '/' && *t == '/')
{
u = ++t;
break;
}
t = u;
while(*u && *u != ':' && *u != '/' && *u != '?')
u++;
host = String(t, u);

//--- SubFolder (JJ)
while(*u && *u != '/' && *u != '?') u++;
if (*u !=0) Subfolder = u;
}
 
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: Thu Jun 12 06:19:25 CEST 2025

Total time taken to generate the page: 0.03751 seconds