libnx
socket.h
1 #pragma once
2 #include "../../types.h"
3 
4 /// Configuration structure for socketInitalize
5 typedef struct {
6  u32 bsdsockets_version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0.
7 
8  u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed).
9  u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed).
10  u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
11  u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value.
12 
13  u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes).
14  u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes).
15 
16  u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8).
17 
18  size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo.
19  size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr.
20  bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon.
21  int dns_timeout; ///< For DNS requests: timeout or 0.
23 
24 /// Fetch the default configuration for the socket driver.
25 const SocketInitConfig *socketGetDefaultInitConfig(void);
26 /// Initalize the socket driver.
27 Result socketInitialize(const SocketInitConfig *config);
28 /// Fetch the last bsd:u/s Switch result code (thread-local).
29 Result socketGetLastBsdResult(void);
30 /// Fetch the last sfdnsres Switch result code (thread-local).
31 Result socketGetLastSfdnsresResult(void);
32 /// Deinitialize the socket driver.
33 void socketExit(void);
34 
35 /// Initalize the socket driver using the default configuration.
36 static inline Result socketInitializeDefault(void) {
37  return socketInitialize(socketGetDefaultInitConfig());
38 }
39 
u32 tcp_rx_buf_size
Size of the TCP recieve buffer (initial or fixed).
Definition: socket.h:9
u32 tcp_tx_buf_max_size
Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its in...
Definition: socket.h:10
size_t serialized_out_hostent_max_size
For gethostbyname/gethostbyaddr.
Definition: socket.h:19
u32 Result
Function error code result type.
Definition: types.h:46
u32 tcp_rx_buf_max_size
Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial va...
Definition: socket.h:11
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
size_t serialized_out_addrinfos_max_size
For getaddrinfo.
Definition: socket.h:18
Configuration structure for socketInitalize.
Definition: socket.h:5
u32 tcp_tx_buf_size
Size of the TCP transfer (send) buffer (initial or fixed).
Definition: socket.h:8
u32 udp_rx_buf_size
Size of the UDP receive buffer (typically 0xA500 bytes).
Definition: socket.h:14
bool bypass_nsd
For name gethostbyname/getaddrinfo: bypass the Name Server Daemon.
Definition: socket.h:20
u32 sb_efficiency
Number of buffers for each socket (standard values range from 1 to 8).
Definition: socket.h:16
u32 udp_tx_buf_size
Size of the UDP transfer (send) buffer (typically 0x2400 bytes).
Definition: socket.h:13
u32 bsdsockets_version
Observed 1 on 2.0 LibAppletWeb, 2 on 3.0.
Definition: socket.h:6
int dns_timeout
For DNS requests: timeout or 0.
Definition: socket.h:21