Make sure that the object is alive as long as handlers that may use it exist.
Make sure that the object is alive as long as handlers that may use it exist. It is likely what one of handlers that uses this socket is called after you call close (as it reports the error to handler) and then accesses to dead pointer... Usually, life time handling can be easily done with boost::shared_ptr and boost::enable_shared_from_this and passing it in handlers. See numerous examples provided with Boost.Asio.
Once you get familiar with this technique the question you asked would look trivial for you.
I would prefer not to use smart pointers, as raw pointers are more native for me. – vladimir Dec 9 '10 at 11:35 5 @vladimir, just because you feel something is more native, does not make it good practice. Smart pointers solve a lot of problems that otherwise can be a ballache :) – Moo-Juice Dec 9 '10 at 11:37 +1 for the use of "ballache" in a sentence.
– Andres Jaan Tack Nov 5 at 16:31.
You do want to look into the shutdown method on a socket as well. It will not solve your crashing application. Artyom above already explained the cause of that, but it is interesting nonetheless.
If you close a socket without calling shutdown it might result in a RST being send instead of a gracefull FIN handshake.
Surely it only results in a RST if you explicitly turn off lingering... – Len Holgate Dec 9 '10 at 12:29.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.