fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

Partial shutdown socket handle release. #82

Open vrishe opened 1 year ago

vrishe commented 1 year ago

Does partial shutdown modes (SHUT_RD, SHUT_WR) should necessarily release the socket handle?

It becomes a bit of a hassle to achieve something like the following:

auto conn_h = conn.release();
{
  sockpp::socket sd_sock(conn_h);
  // We end up with writing on client side explicitly,
  // so the receiver's aware an icoming data stream is over.
  if (!sd_sock.shutdown(SHUT_WR))
    throw io::transfer_error::from_sock(sd_sock);
}
sockpp::stream_socket rd_sock(conn_h);
// read the response through rd_sock here
// ...