6

How to cancel asynchronous read/write without closing the socket? I use boost.asio. Thanks.

niXman
  • 1,698
  • 3
  • 16
  • 40

1 Answers1

9

Use socket::cancel.

Cancel all asynchronous operations associated with the socket.

Sam Miller
  • 23,808
  • 4
  • 67
  • 87
  • However, we note from the linked documentation: * It will only cancel asynchronous operations that were initiated in the current thread. * It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. – Sam Liddicott Mar 02 '16 at 14:26
  • @SamLiddicott Please note that this applies only to CancelIo (Windows) , if enabled by BOOST_ASIO_ENABLE_CANCELIO – LangerJan Mar 09 '16 at 14:28
  • @SamMiller That is such a relief! Thanks for clarifying! – Sam Liddicott Mar 09 '16 at 18:26