SOCU:poll: Difference between revisions

Mtheall (talk | contribs)
DaniElectra (talk | contribs)
Events: Update poll events. The 3DS doesn't use the same event flags as the Wii
 
(One intermediate revision by one other user not shown)
Line 77: Line 77:


=Events=
=Events=
Events are a bitwise set of these flags.
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.
 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Value
! Value
! Name
! Name
! Input/Output
! Description
! Description
|-
|-
| 0x01
| 0x01
| POLLIN
| POLLIN
| Both
| Data can be read.
| Can recv() data from socket without blocking. For listen sockets, this means you can accept() a connection without blocking.
|-
|-
| 0x02
| 0x02
| POLLPRI
| POLLPRI
| Both
| Urgent data can be read.
| There is OOB data ready to recv(). Appears that recv()'ing without OOB flag still reads OOB data?
|-
| 0x04
| ???
| ???
| Have never seen this flag. Could possibly be POLLHUP (need to test).
|-
|-
| 0x08
| 0x08
| POLLERR
| POLLWRNORM
| Out
| Normal data can be written.
| Socket has an error condition.
|-
|-
| 0x10
| 0x10
| POLLOUT
| POLLWRBAND
| Both
| Priority data can be written.
| Can send() data to socket without blocking. For a non-blocking connect(), this means the connection has completed (need to test).
|-
|-
| 0x20
| 0x20
| POLLNVAL
| POLLNVAL
| Out
| Invalid socket handle.
| Invalid socket handle. This is set if you use fd=-1, which is non-standard behavior.
|-
|-
| ???
| POLLWRNORM
| POLLHUP
| POLLOUT
| Out
| Data can be written.
| Socket has been disconnected.
|}
|}
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.