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
Example
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <unistd.h>
#include <arpa/inet.h>
#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
}