Added fr::TcpSocket::shutdown to shutdown a socket

This commit is contained in:
Cloaked9000 2016-12-20 10:07:40 +00:00
parent 2de9540819
commit 9db918c7c2
2 changed files with 15 additions and 0 deletions

View File

@ -91,6 +91,16 @@ public:
*/ */
int32_t get_socket_descriptor() const override; int32_t get_socket_descriptor() const override;
/*!
* Calls the shutdown syscall on the socket.
* So you can receive data but not send.
*
* This can be called on a blocking socket to force
* it to immediately return (you might want to do this if
* you're exiting and need the blocking socket to return).
*/
void shutdown();
protected: protected:
std::string unprocessed_buffer; std::string unprocessed_buffer;
std::unique_ptr<char[]> recv_buffer; std::unique_ptr<char[]> recv_buffer;

View File

@ -157,4 +157,9 @@ namespace fr
return socket_descriptor; return socket_descriptor;
} }
void TcpSocket::shutdown()
{
::shutdown(socket_descriptor, 0);
}
} }