In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Nsysnet.rpl"

From WiiUBrew
Jump to navigation Jump to search
(Added SOAccept)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
nsysnet.rpl is the library that provides Berkeley sockets (BSD sockets) related functions. You can find more information about it on [http://en.wikipedia.org/wiki/Berkeley_sockets Wikipedia]
+
nsysnet.rpl is the library that provides Berkeley sockets (BSD sockets), network configuration, and SSL functions.
  
 
==Functions==
 
==Functions==
===Base===
+
===Socket===
 +
Many of these socket functions are standard BSD ones (connect(), recv(), send(), etc.). You can find more information about BSD sockets on [http://en.wikipedia.org/wiki/Berkeley_sockets Wikipedia].
 
{| class="wikitable"
 
{| class="wikitable"
 
!Name
 
!Name
Line 9: Line 10:
 
!Returns
 
!Returns
 
|-
 
|-
|SOInit
+
|socket_lib_init
|<code>int SOInit(void);</code>  
+
|<code>int socket_lib_init(void);</code>  
|Initializes the library.
+
|Initialize the library
 
|SO_*
 
|SO_*
 
|-
 
|-
|SOFinish
+
|socket_lib_finish
|<code>int SOFinish(void);</code>  
+
|<code>int socket_lib_finish(void);</code>  
|Cleans up after the library.
+
|Clean up after the library
 
|SO_*
 
|SO_*
|}
 
 
===Networking===
 
These are also available under their standard BSD names (connect(), recv(), send(), etc.), without the SO* prefix.
 
{| class="wikitable"
 
!Name
 
!Prototype
 
!Description
 
!Returns
 
 
|-
 
|-
|SOConnect
+
|connect
|<code>int SOConnect(int fd, struct sockaddr *addr, int addrlen);</code>  
+
|<code>int connect(int fd, struct sockaddr *addr, int addrlen);</code>  
|Initializes/Accepts connection requests from listing
+
|Connect to the specified host
|A new socket descriptor???
+
|SO_*
 
|-
 
|-
|SOListen
+
|listen
|<code>int SOListen(int fd, int backlog);</code>  
+
|<code>int listen(int fd, int backlog);</code>  
|Listens for connections
+
|Listen for connections
 
|SO_*
 
|SO_*
 
|-
 
|-
|SOAccept
+
|accept
|<code>int SOAccept(int fd, struct sockaddr *addr, int *addrlen);</code>  
+
|<code>int accept(int fd, struct sockaddr *addr, int *addrlen);</code>  
|Same as SOSend but with target specified
+
|Accept connection requests from listening
|SO_*
+
|A new socket descriptor
 
|-
 
|-
|SORecv
+
|recv
|<code>int SORecv(int fd, void *buffer, int len, int flags);</code>  
+
|<code>int recv(int fd, void *buffer, int len, int flags);</code>  
|Receive data from a remote socket  
+
|Receive data over a socket  
 
|SO_*
 
|SO_*
 
|-
 
|-
|SORecvFrom
+
|recvfrom
|<code>int SORecvFrom(int fd, void *buffer, int len, int flags, struct sockaddr *from, int *fromlen);</code>  
+
|<code>int recvfrom(int fd, void *buffer, int len, int flags, struct sockaddr *from, int *fromlen);</code>  
|Same as SORecv but with target specified
+
|Same as recv() but with target specified
 
|SO_*
 
|SO_*
 
|-
 
|-
|SOSend
+
|send
|<code>int SOSend(int fd, const void *buffer, int len, int flags);</code>  
+
|<code>int send(int fd, const void *buffer, int len, int flags);</code>  
|Send data to remote socket
+
|Send data over a socket
 
|SO_*
 
|SO_*
 
|-
 
|-
|SOSendTo
+
|sendto
|<code>int SOSendTo(int fd, const void *buffer, int len, int flags, const struct sockaddr *dest_addr, int dest_len);</code>  
+
|<code>int sendto(int fd, const void *buffer, int len, int flags, const struct sockaddr *dest_addr, int dest_len);</code>  
|Same as SOSend but with target specified
+
|Same as send() but with target specified
 
|SO_*
 
|SO_*
|}
 
 
===Error===
 
{| class="wikitable"
 
!Name
 
!Prototype
 
!Description
 
!Returns
 
 
|-
 
|-
|SOInit
+
|socklasterr
|<code>int SOLastError(void);</code>  
+
|<code>int socklasterr(void);</code>  
|Recives the latest error???
+
|Return the most recently recorded socket error code
|The latest error(SO_*)???
+
|The latest error(SO_*)
 
|}
 
|}
  
Line 85: Line 69:
 
|
 
|
 
<syntaxhighlight lang="C">
 
<syntaxhighlight lang="C">
typedef struct {
+
typedef struct
 +
{
 
     u16 sin_family;
 
     u16 sin_family;
 
     u16 sin_port;
 
     u16 sin_port;
     struct in_addr sin_addr;
+
     struct in_addr sin_addr;
 
     char sin_zero[8];
 
     char sin_zero[8];
 
} sockaddr_in;
 
} sockaddr_in;
 +
</syntaxhighlight>
 +
|-
 +
|sockaddr_in
 +
|
 +
<syntaxhighlight lang="C">
 +
typedef struct
 +
{
 +
    u32 s_addr;
 +
} in_addr;
 
</syntaxhighlight>
 
</syntaxhighlight>
 
|}
 
|}

Latest revision as of 20:17, 24 April 2016

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

Functions

Socket

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_*)

Structures

Name Data
sockaddr_in
typedef struct
{
    u16 sin_family;
    u16 sin_port;
    struct in_addr sin_addr;
    char sin_zero[8];
} sockaddr_in;
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?