recv() with large buffer size
Posted: Wed Jun 30, 2021 5:50 am
I'm trying to implement multiplayer for Switch in DevilutionX, but I don't actually have a Switch console I can use to run homebrew applications. I've been doing my testing with Ryujinx and have been asking members of the DevilutionX community to do testing on the Switch console.
When I was testing with Ryujinx, I encountered an error when attempting to receive data on a socket. I initially assumed this was a Ryujinx issue and used a workaround to make the game work for my testing. However, it seems that the same error occurs when testing on the Switch console as well. You can see more details in an issue I opened on their GitHub issue tracker.
https://github.com/Ryujinx/Ryujinx/issues/2393
I've been digging through IPC marshalling documentation and libnx code to try to understand what a 0x22 buffer is, and why this failure is occurring. Honestly, based on my limited understanding of the IPC marshalling, I wasn't able to identify any obvious issues in libnx. However, I did learn that the code in DevilutionX was using a sufficiently large buffer that the HIPC auto-selection is attempting to use buffer descriptor B instead of buffer descriptor C for these requests.
I started experimenting with different buffer sizes in a simple test program by merging the nxlink example with code from https://www.thegeekstuff.com/2011/12/c- ... ogramming/. It seems that the recv() function fails in Ryujinx for buffer sizes greater than 32768. Given that I'm not able to test this against the Switch console, I was a bit hesitant to post it as a libnx issue. I was wondering if anyone here had any more information about why the recv() function fails for large buffer sizes.
I've attached the source code for the test program. The server code runs on Linux, and the client runs on the Switch. I ran the server and Ryujinx on the same system so the IP address is hardcoded in client.c to 127.0.0.1.
When I was testing with Ryujinx, I encountered an error when attempting to receive data on a socket. I initially assumed this was a Ryujinx issue and used a workaround to make the game work for my testing. However, it seems that the same error occurs when testing on the Switch console as well. You can see more details in an issue I opened on their GitHub issue tracker.
https://github.com/Ryujinx/Ryujinx/issues/2393
I've been digging through IPC marshalling documentation and libnx code to try to understand what a 0x22 buffer is, and why this failure is occurring. Honestly, based on my limited understanding of the IPC marshalling, I wasn't able to identify any obvious issues in libnx. However, I did learn that the code in DevilutionX was using a sufficiently large buffer that the HIPC auto-selection is attempting to use buffer descriptor B instead of buffer descriptor C for these requests.
I started experimenting with different buffer sizes in a simple test program by merging the nxlink example with code from https://www.thegeekstuff.com/2011/12/c- ... ogramming/. It seems that the recv() function fails in Ryujinx for buffer sizes greater than 32768. Given that I'm not able to test this against the Switch console, I was a bit hesitant to post it as a libnx issue. I was wondering if anyone here had any more information about why the recv() function fails for large buffer sizes.
I've attached the source code for the test program. The server code runs on Linux, and the client runs on the Switch. I ran the server and Ryujinx on the same system so the IP address is hardcoded in client.c to 127.0.0.1.