Merge pull request #4113 from namkazt/soc_recv_from
fix soc service - RecvFrom - SendTo
This commit is contained in:
commit
d1a576eb14
1 changed files with 15 additions and 8 deletions
|
@ -545,11 +545,10 @@ void SOC_U::SendTo(Kernel::HLERequestContext& ctx) {
|
||||||
auto input_buff = rp.PopStaticBuffer();
|
auto input_buff = rp.PopStaticBuffer();
|
||||||
auto dest_addr_buff = rp.PopStaticBuffer();
|
auto dest_addr_buff = rp.PopStaticBuffer();
|
||||||
|
|
||||||
CTRSockAddr ctr_dest_addr;
|
|
||||||
std::memcpy(&ctr_dest_addr, dest_addr_buff.data(), sizeof(ctr_dest_addr));
|
|
||||||
|
|
||||||
s32 ret = -1;
|
s32 ret = -1;
|
||||||
if (addr_len > 0) {
|
if (addr_len > 0) {
|
||||||
|
CTRSockAddr ctr_dest_addr;
|
||||||
|
std::memcpy(&ctr_dest_addr, dest_addr_buff.data(), sizeof(ctr_dest_addr));
|
||||||
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
|
sockaddr dest_addr = CTRSockAddr::ToPlatform(ctr_dest_addr);
|
||||||
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
|
ret = ::sendto(socket_handle, reinterpret_cast<const char*>(input_buff.data()), len, flags,
|
||||||
&dest_addr, sizeof(dest_addr));
|
&dest_addr, sizeof(dest_addr));
|
||||||
|
@ -624,12 +623,20 @@ void SOC_U::RecvFrom(Kernel::HLERequestContext& ctx) {
|
||||||
std::vector<u8> addr_buff(sizeof(ctr_src_addr));
|
std::vector<u8> addr_buff(sizeof(ctr_src_addr));
|
||||||
sockaddr src_addr;
|
sockaddr src_addr;
|
||||||
socklen_t src_addr_len = sizeof(src_addr);
|
socklen_t src_addr_len = sizeof(src_addr);
|
||||||
s32 ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
|
|
||||||
&src_addr, &src_addr_len);
|
|
||||||
|
|
||||||
if (ret >= 0 && src_addr_len > 0) {
|
s32 ret = -1;
|
||||||
ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
|
if (addr_len > 0) {
|
||||||
std::memcpy(addr_buff.data(), &ctr_src_addr, sizeof(ctr_src_addr));
|
// Only get src adr if input adr available
|
||||||
|
ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
|
||||||
|
&src_addr, &src_addr_len);
|
||||||
|
if (ret >= 0 && src_addr_len > 0) {
|
||||||
|
ctr_src_addr = CTRSockAddr::FromPlatform(src_addr);
|
||||||
|
std::memcpy(addr_buff.data(), &ctr_src_addr, sizeof(ctr_src_addr));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = ::recvfrom(socket_handle, reinterpret_cast<char*>(output_buff.data()), len, flags,
|
||||||
|
NULL, 0);
|
||||||
|
addr_buff.resize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 total_received = ret;
|
s32 total_received = ret;
|
||||||
|
|
Loading…
Reference in a new issue