htcs: fixes, echo server is now fully functional

This commit is contained in:
Michael Scire 2021-02-21 14:31:28 -08:00 committed by SciresM
parent 72de4d85f3
commit 0ec54ed492
8 changed files with 33 additions and 19 deletions

View file

@ -15,8 +15,13 @@
*/
#include <stratosphere.hpp>
#include "htcs_session.hpp"
extern "C" {
#include <switch/services/htcs.h>
}
namespace ams::htcs::client {
namespace {
@ -32,6 +37,10 @@ namespace ams::htcs::client {
}
} g_static_allocator_initializer;
}
namespace {
class RemoteSocket {
private:
::HtcsSocket m_s;
@ -112,6 +121,8 @@ namespace ams::htcs::client {
::HtcsSocket libnx_socket;
R_TRY(::htcsCreateSocket(out_err.GetPointer(), std::addressof(libnx_socket), enable_disconnection_emulation));
R_SUCCEED_IF(*out_err != 0);
*out = ObjectFactory::CreateSharedEmplaced<tma::ISocket, RemoteSocket>(libnx_socket);
return ResultSuccess();
}
@ -160,7 +171,6 @@ namespace ams::htcs::client {
return ::htcsSocketFcntl(std::addressof(m_s), out_err.GetPointer(), out_res.GetPointer(), command, value);
}
Result RemoteSocket::AcceptStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event) {
return ::htcsSocketAcceptStart(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer());
}
@ -170,6 +180,8 @@ namespace ams::htcs::client {
::HtcsSocket libnx_socket;
R_TRY(::htcsSocketAcceptResults(std::addressof(m_s), out_err.GetPointer(), std::addressof(libnx_socket), reinterpret_cast<::SockAddrHtcs *>(out_address.GetPointer()), task_id));
R_SUCCEED_IF(*out_err != 0);
*out = ObjectFactory::CreateSharedEmplaced<tma::ISocket, RemoteSocket>(libnx_socket);
return ResultSuccess();
}