sock: change Sock::SendComplete() to take Span

This would make it easier to pass other than `std::string` types,
to be used in the `Socks5()` function.
This commit is contained in:
Vasil Dimov committed 2023-10-31 18:19:22 +01:00
1 parent 73dfa6da08
commit 1b19d1117c
2 files changed
+16 -2

No files matched your search

+8 -1
View File
@@ -242,7 +242,7 @@ bool Sock::WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per
#endif /* USE_POLL */ #endif /* USE_POLL */
} }
void Sock::SendComplete(const std::string& data, void Sock::SendComplete(Span<const unsigned char> data,
std::chrono::milliseconds timeout, std::chrono::milliseconds timeout,
CThreadInterrupt& interrupt) const CThreadInterrupt& interrupt) const
{ {
@@ -283,6 +283,13 @@ void Sock::SendComplete(const std::string& data,
} }
} }
void Sock::SendComplete(Span<const char> data,
std::chrono::milliseconds timeout,
CThreadInterrupt& interrupt) const
{
SendComplete(MakeUCharSpan(data), timeout, interrupt);
}
std::string Sock::RecvUntilTerminator(uint8_t terminator, std::string Sock::RecvUntilTerminator(uint8_t terminator,
std::chrono::milliseconds timeout, std::chrono::milliseconds timeout,
CThreadInterrupt& interrupt, CThreadInterrupt& interrupt,
+8 -1
View File
@@ -228,7 +228,14 @@ public:
* @throws std::runtime_error if the operation cannot be completed. In this case only some of * @throws std::runtime_error if the operation cannot be completed. In this case only some of
* the data will be written to the socket. * the data will be written to the socket.
*/ */
virtual void SendComplete(const std::string& data, virtual void SendComplete(Span<const unsigned char> data,
std::chrono::milliseconds timeout,
CThreadInterrupt& interrupt) const;
/**
* Convenience method, equivalent to `SendComplete(MakeUCharSpan(data), timeout, interrupt)`.
*/
virtual void SendComplete(Span<const char> data,
std::chrono::milliseconds timeout, std::chrono::milliseconds timeout,
CThreadInterrupt& interrupt) const; CThreadInterrupt& interrupt) const;