Open yinpengji opened 11 years ago
The iostream transport now includes eof()
and fatal_error()
methods that can be used by the part of your program feeding bytes to the connection to signal these conditions to the library as appropriate. In general if you are reading from a socket and you get EOF on your socket you should signal EOF to the transport. Same with another type of socket error. If you are not actually backed by a socket but by something else (reading a canned connection from a file, or other stream) you may need to play around with exactly when it would be appropriate to "simulate" an EOF or transport error. This should enable the full proper close behavior for the library.
I'm working on some additional documentation about how to use the iostream transport to full effect.
If I understand correctly, if I feed all the data from the socket to the websocket++ lib, if the data contains EOF, the websocket++ will call eof() by itself, and I do not need to call eof() explicitly, right? The same with fatal_error.
If no error happens from the socket during the connection, I just want to clean up the resource before the websocket++ lib get EOF data, I just need to call eof() manually, right?
I'm using the iostream client as an engine to generate/access payload from sockets. Everything works fine except that after close is called, the on_close callback will never be called.
I debugged into the code and found the code below: websocketpp_0_3_x\websocketpp\impl\connection_impl.hpp at line 1756