diff --git a/Networking.md b/Networking.md new file mode 100644 index 0000000..deec130 --- /dev/null +++ b/Networking.md @@ -0,0 +1,34 @@ +In order to use sockets in your homebrew application, you'll first need to initialize the SOC service by calling `SOC_Initialize()`. When your application finishes, use `SOC_Shutdown()` to close the service gracefully. The headers and documentation for these functions can be viewed here: [3ds/services/soc.h](https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/services/soc.h) + +### Example + +```c +#include +#include +#include +#include +#include +#include +#include <3ds.h> + +int main() +{ + // Initialize graphics and console + gfxInitDefault(); + gfxSet3D(false); + consoleInit(GFX_BOTTOM, NULL); + + // Initialize SOC + SOC_Initialize((u32*)memalign(0x1000, 0x128000), 0x128000); + + // Do networking stuff + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + // ... + close(sockfd); + + // Cleanup SOC + SOC_Shutdown(); + + return 0 +} +``` \ No newline at end of file