@@ -491,6 +491,37 @@ class basic_serial_port
491491 return impl_.get_service ().native_handle (impl_.get_implementation ());
492492 }
493493
494+ // / Release ownership of the underlying native serial port.
495+ /*
496+ * This function causes all outstanding asynchronous read operations to
497+ * finish immediately, and the handlers for cancelled operations will be
498+ * passed the asio::error::operation_aborted error. Ownership of the
499+ * native serial port is then transferred to the caller.
500+ *
501+ * @throws asio::system_error Thrown on failure.
502+ */
503+ native_handle_type release ()
504+ {
505+ asio::error_code ec;
506+ native_handle_type s = impl_.get_service ().release (
507+ impl_.get_implementation (), ec);
508+ asio::detail::throw_error (ec, " release" );
509+ return s;
510+ }
511+
512+ // / Release ownership of the underlying native serial port.
513+ /*
514+ * This function causes all outstanding asynchronous read operations to
515+ * finish immediately, and the handlers for cancelled operations will be
516+ * passed the asio::error::operation_aborted error. Ownership of the
517+ * native serial port is then transferred to the caller.
518+ *
519+ * @param ec Set to indicate what error occurred, if any.
520+ */
521+ native_handle_type release (asio::error_code& ec)
522+ {
523+ return impl_.get_service ().release (impl_.get_implementation (), ec);
524+ }
494525 // / Cancel all asynchronous operations associated with the serial port.
495526 /* *
496527 * This function causes all outstanding asynchronous read or write operations
0 commit comments