htcs: fixes, echo server is now fully functional
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -207,7 +207,6 @@ namespace ams::htcs::client {
|
||||
error_code = 0;
|
||||
|
||||
/* Create the socket. */
|
||||
sf::SharedPointer<tma::ISocket> socket(nullptr);
|
||||
return this->CreateSocket(sf::SharedPointer<tma::ISocket>{nullptr}, error_code);
|
||||
}
|
||||
|
||||
@@ -579,7 +578,7 @@ namespace ams::htcs::client {
|
||||
|
||||
/* Add the socket to the list. */
|
||||
if (m_list_count != 0) {
|
||||
/* Ensure the list remains in sorder order. */
|
||||
/* Ensure the list remains in sorted order. */
|
||||
s32 index;
|
||||
for (index = m_list_count - 1; index >= 0; --index) {
|
||||
if (m_socket_list[index].m_id < id) {
|
||||
@@ -687,7 +686,7 @@ namespace ams::htcs::client {
|
||||
s32 error_code = 0;
|
||||
|
||||
/* Get socket. */
|
||||
sf::SharedPointer<tma::ISocket> res = socket(id);
|
||||
sf::SharedPointer<tma::ISocket> res = socket(error_code);
|
||||
if (res != nullptr) {
|
||||
/* Assign the new socket. */
|
||||
s32 index;
|
||||
|
||||
Reference in New Issue
Block a user