Socket Services

Socket Services

The socket sysmodule has a maximum limit of 64 sockets in total.

Socket user service “soc:U” #

There can be up to 18 sessions of this service.

Command HeaderAvailable since system-versionDescription
0x00010044InitializeSockets
0x000200C2socket
0x00030082listen
0x00040082accept
0x00050084bind
0x00060084connect
0x00070104recvfrom_other
0x00080102recvfrom
0x00090106sendto_other
0x000A0106sendto
0x000B0042close
0x000C0082shutdown
0x000D0082gethostbyname
0x000E00C2gethostbyaddr
0x000F0106getaddrinfo
0x00100102getnameinfo
0x00110102getsockopt
0x00120104setsockopt
0x001300C2fcntl
0x00140084poll
0x00150042sockatmark
0x00160000gethostid
0x00170082getsockname
0x00180082getpeername
0x00190000ShutdownSockets
0x001A00C0GetNetworkOpt
0x001B0040ICMPSocket
0x001C0104ICMPPing
0x001D0040ICMPCancel
0x001E0040ICMPClose
0x001F0040GetResolverInfo
0x00200146SendToMultiple
0x00210002CloseSockets
0x00220040(int sockfd) Might be the inverse of command 0x00230040?
0x00230040AddGlobalSocket
0x100100C0??
0x10030142??
0x10050084??
0x10070102??

Socket privileged service “soc:P” #

There can be up to 3 sessions of this service.

Command HeaderDescription
0x00010084InitializeSockets
0x00020000FinalizeSockets
0x000300C2SetNetworkOpt
0x00040040CloseSocketsForProcess
0x000500C0
0x00060000gethostid
0x00070000
0x00080000
0x00090000StopInitializeSockets

struct sockaddr #

OffsetSizeDescription
0x00x1Total size of the entire sockaddr buffer.
0x10x1u8 sa_family
0x2sockaddr_totalsize-0x2sa_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 #

ErrorDescription
0xC8A07004This is returned when trying to use a socket descriptor from a different process.
0xC8A07009Network dropped connection on reset? (Translated from ENETRESET error)
0xC8A0700BSOCU:InitializeSockets returns this when the specified PID was already used with SOCU:InitializeSockets(since the PID was found in SOC module state table).
0xD860700ASOCU:InitializeSockets returns this when the PID table is already full(32 processes max).
0xD8E07006Not initialized. This is returned when SOCU:InitializeSockets has not been run.
0xD8E07007The given socket descriptor does not exist.

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 IDcommands
0bind,connect
1sendto_other,sendto
2sendto
5-7getaddrinfo
8getnameinfo
9setsockopt
10poll

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
};

Category:Services