|
5 | 5 | * After initializing this service you will be able to use system calls from netdb.h, sys/socket.h etc. |
6 | 6 | */ |
7 | 7 | #pragma once |
| 8 | +#include <3ds/types.h> |
8 | 9 | #include <netinet/in.h> |
9 | 10 | #include <sys/socket.h> |
10 | 11 |
|
11 | 12 | /// The config level to be used with @ref SOCU_GetNetworkOpt |
12 | 13 | #define SOL_CONFIG 0xfffe |
13 | 14 |
|
| 15 | +/// Default number of SOC sessions to initialize, for backwards compatibility |
| 16 | +#define SOC_DEFAULT_NUM_SESSIONS 1 |
| 17 | + |
14 | 18 | /// Options to be used with @ref SOCU_GetNetworkOpt |
15 | 19 | typedef enum |
16 | 20 | { |
@@ -101,9 +105,19 @@ typedef struct |
101 | 105 | * @param context_addr Address of a page-aligned (0x1000) buffer to be used. |
102 | 106 | * @param context_size Size of the buffer, a multiple of 0x1000. |
103 | 107 | * @note The specified context buffer can no longer be accessed by the process which called this function, since the userland permissions for this block are set to no-access. |
| 108 | + * @note The SOC service can only be used in a single thread when using this function to initialize SOC services. In order to enable usage across multiple threads, use @ref socInitMulti, otherwise threads will block when using socket functions concurrently. |
104 | 109 | */ |
105 | 110 | Result socInit(u32 *context_addr, u32 context_size); |
106 | 111 |
|
| 112 | +/** |
| 113 | + * @brief Initializes the SOC service for use across multiple threads. |
| 114 | + * @param context_addr Address of a page-aligned (0x1000) buffer to be used. |
| 115 | + * @param context_size Size of the buffer, a multiple of 0x1000. |
| 116 | + * @param num_sessions The number of sessions to initialize. This value determines how many socket functions can be run concurrently. Setting it to 1 means only one thread can safely use socket functions. |
| 117 | + * @note The specified context buffer can no longer be accessed by the process which called this function, since the userland permissions for this block are set to no-access. |
| 118 | + */ |
| 119 | +Result socInitMulti(u32 *context_addr, u32 context_size, u32 num_sessions); |
| 120 | + |
107 | 121 | /** |
108 | 122 | * @brief Closes the soc service. |
109 | 123 | * @note You need to call this in order to be able to use the buffer again. |
|
0 commit comments