From 2ef5b18d1fd3ff6e7588717b0eec1b109b018de6 Mon Sep 17 00:00:00 2001 From: Stephen Eisenhauer Date: Thu, 8 Oct 2015 00:19:50 -0700 Subject: [PATCH] Created Networking (markdown) --- Networking.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Networking.md 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