Socket user service "soc:U"

Command Header Available since system-version Description
0x00010044 InitializeSockets
0x000200C2 socket
0x00030082 listen
0x00040082 accept
0x00050084 bind
0x00060084 connect
0x00070104 recvfrom_other
0x00080102 recvfrom
0x00090106 sendto_other
0x000A0106 sendto
0x000B0042 close
0x000C0082 shutdown
0x000D0082 gethostbyname
0x000E00C2 gethostbyaddr
0x000F0106 getaddrinfo
0x00100102 getnameinfo
0x00110102 getsockopt
0x00120104 setsockopt
0x001300C2 fcntl
0x00140084 poll
0x00150042 sockatmark
0x00160000 gethostid
0x00170082 getsockname
0x00180082 getpeername
0x00190000 ShutdownSockets
0x001A00C0 GetNetworkOpt
0x001B0040 ICMPSocket
0x001C0104 ICMPPing
0x001D0040 ICMPCancel
0x001E0040 ICMPClose
0x001F0040 GetResolverInfo
0x00200146 ?
0x00210002 CloseSockets
0x00220040 (int sockfd) Might be the inverse of command 0x00230040?
0x00230040 AddGlobalSocket
0x100100C0 ? ?
0x10030142 ? ?
0x10050084 ? ?
0x10070102 ? ?

Socket privileged service "soc:P"

Command Header Description
0x00010084 InitializeSockets
0x00020000 FinalizeSockets
0x000300C2 SetNetworkOpt
0x00040040 CloseSocketsForProcess
0x000500C0
0x00060000 gethostid
0x00070000
0x00080000
0x00090000 StopInitializeSockets

struct sockaddr

Offset Size Description
0x0 0x1 Total size of the entire sockaddr buffer.
0x1 0x1 u8 sa_family
0x2 sockaddr_totalsize-0x2 sa_data[]

The total buffer size is 0x8, for family AF_INET value 2. AF_INET6 seems to be value 23, the total sockaddr size for this is 0x1C. The max sockaddr buffer size which the socket module can handle is size 0x1C.

These socket services(and defines/structures) seem to be based on the Wii sockets?

Socket module errors

Error Description
0xC8A0700B SOCU:InitializeSockets returns this when the specified PID was already used with SOCU:InitializeSockets(since the PID was found in SOC module state table).
0xD860700A SOCU:InitializeSockets returns this when the PID table is already full(32 processes max).

Socket module static buffers

This is the list of the known thread static buffers in use for SOC:u and the commands using those.

buffer ID commands
0 bind,connect
1 sendto_other,sendto
2 sendto
5-7 getaddrinfo
8 getnameinfo
9 setsockopt
10 poll

IPV6

It seems that Nintendo planned ahead and included IPv6 support to some extent in their code. Name resolution functions support IPv6 (such as getnameinfo), but socket doesn't.

The ipv6 sockaddr size is 0x1C and is required for some IPC commands, even when using sockaddr_in which in reality is of size 8. The sockaddr_in6 struct is the following:

struct in6_addr
{
	uint8_t s6_addr[16];
};

struct sockaddr_in6
{
    sa_family_t     sin6_family;
    in_port_t       sin6_port;
    struct in6_addr sin6_addr;
    u32             sin6_flowinfo; // Not confirmed
    u32             sin6_scope_id; // Not confirmed
};