From WiiUBrew
Jump to navigation Jump to search

nsysnet.rpl is the library that provides Berkeley sockets (BSD sockets), network configuration, and SSL functions.



Many of these socket functions are standard BSD ones (connect(), recv(), send(), etc.). You can find more information about BSD sockets on Wikipedia.

Name Prototype Description Returns
socket_lib_init int socket_lib_init(void); Initialize the library SO_*
socket_lib_finish int socket_lib_finish(void); Clean up after the library SO_*
connect int connect(int fd, struct sockaddr *addr, int addrlen); Connect to the specified host SO_*
listen int listen(int fd, int backlog); Listen for connections SO_*
accept int accept(int fd, struct sockaddr *addr, int *addrlen); Accept connection requests from listening A new socket descriptor
recv int recv(int fd, void *buffer, int len, int flags); Receive data over a socket SO_*
recvfrom int recvfrom(int fd, void *buffer, int len, int flags, struct sockaddr *from, int *fromlen); Same as recv() but with target specified SO_*
send int send(int fd, const void *buffer, int len, int flags); Send data over a socket SO_*
sendto int sendto(int fd, const void *buffer, int len, int flags, const struct sockaddr *dest_addr, int dest_len); Same as send() but with target specified SO_*
socklasterr int socklasterr(void); Return the most recently recorded socket error code The latest error(SO_*)


Name Data
typedef struct
    u16 sin_family;
    u16 sin_port;
    struct in_addr sin_addr;
    char sin_zero[8];
} sockaddr_in;
typedef struct
    u32 s_addr;
} in_addr;

Error Codes

The error codes that SO functions can return. if the error code starts with "SO_E" so were the operation not successful otherwise it were.

Name Value Description
SO_SUCCESS 0 The operation were successful
SO_ETIMEDOUT 2 The connection timed out
SO_ECONNREFUSED 7 The connection were refused
SO_ERROR 41 The operation hit a generic error and were not successful
SO_ELIBNOTREADY 43 The library is not ready, did you forget to initialize it?