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 #49553 is a reply to message #49529] Wed, 28 February 2018 15:24 Go to previous messageGo to previous message
uppjj is currently offline  uppjj
Messages: 9
Registered: February 2018
Location: France
Promising Member
Hello Mirek

Thanks for your very quick answer !
Two things to report :

1)A little bug : you forgot to add mask for short lengths (line 453):

(if(len > 125) {
header.Cat(126 | mask);
...
else
header.Cat((int)len | mask);


2)Url connection not so easy:
RequestHeader() must be completed before using "Connect" ...but needs informations calculated by Connect (uri, host) !
Header beginning example :
"GET " + uri + " HTTP/1.1\r\n"
"Host: " + host + "\r\n"
...

in your code uri = url (not very useful) so I use uri to separate "Host" (ex: ws://demos.kaazing.com ) and sub-adress (ex : /echo) , because this is (in my case) required by the remote server:

//--- Port
int port = ssl ? 443 : 80;
if(*u == ':')
port = ScanInt(u + 1, &u);

//--- uri (JJ)
while(*u && *u != '/' && *u != '?') u++;
if (*u !=0) uri = u; // only sub-adress


Url is the complete adress and uri is the sub-adress than can be used by GET

Solution should be to remove host, port, uri (and may be websocket-key to) calculations from Connect, into a separate function that could be used before Connect() to complete RequestHeader().

Best Regards
Jean-Jacques
 
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: Mon May 06 22:47:45 CEST 2024

Total time taken to generate the page: 0.02664 seconds