SOCU:poll

SOCU:poll

Request #

Index WordDescription
0Header code [0x00140084]
1nfds_t nfds
2int timeout
3Value 0x20 (processID header)
4ProcessID set by the ARM11 kernel.
5(insize<<14) | 0x2802
6Pointer to input pollfd struct array

The following is located 0x100-bytes after the beginning of the above command buffer:

Index WordDescription
0(outsize<<14) | 2
1Pointer to output pollfd struct array

Response #

Index WordDescription
0Header code
1Result code
2POSIX return value

pollfd struct #

TypeNameDescription
u32fdSocket handle
u32eventsEvents to poll for (input)
u32reventsEvents received (output)

Events #

Events are a bitwise set of these flags. These flags don’t exactly match the Wii flags, even though the sockets sysmodule uses the same codebase.

ValueNameDescription
0x01POLLINData can be read.
0x02POLLPRIUrgent data can be read.
0x08POLLWRNORMNormal data can be written.
0x10POLLWRBANDPriority data can be written.
0x20POLLNVALInvalid socket handle.
POLLWRNORMPOLLOUTData can be written.

Flag 0x4 isn’t ever assigned in the code. Flags 0x40 and 0x80 are also not used, even though they are assgined in the input events by default along with 0x20. This is likely because that code section was inherited from the Wii, where these flags are used for poll errors.

Contrary to the Wii sockets, the 3DS doesn’t have POLLERR or POLLHUP, so poll shouldn’t be relied on when checking for socket errors.