Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] Closing async client socket after writing last message
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-06-22 21:58:26

On 19/06/2014 06:48, Nicholas Yue wrote:
> I have adapted the chat tutorial example to send messages to a
> similar (chat tutorial based) server.
> It is currently working fine however due to the async_write(), I
> can't close the socket until after all the pending data has been
> processed on the server end.
> I have google and found discussion and mentioned about async_write()
> completion handler calling socket.close() however, I was not able to
> find specific detail as to how that is done.

Do you want something like an actual chat server where connection close
can occur at any arbitrary time unrelated to data transmission, or
something more like HTTP/FTP where you know in advance that you want to
close the connection immediately following a particular transmit?

Because these two patterns have different solutions, and the ones being
discussed in this thread so far are mostly the former while the one you
mentioned in the last quoted paragraph above is for the latter (and is
much simpler).

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at