-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable networking and stdio on Switch platform
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <switch.h> | ||
#include "platform/switch/network.h" | ||
|
||
static int nxlink_sock = -1; // for stdio on Switch | ||
|
||
void switch_enable_network() | ||
{ | ||
// enable network and stdio on Switch | ||
socketInitializeDefault(); | ||
// enable error messages via nxlink on Switch | ||
nxlink_sock = nxlinkStdio(); | ||
atexit(switch_disable_network); | ||
} | ||
|
||
void switch_disable_network() | ||
{ | ||
// disable network and stdio on Switch | ||
if (nxlink_sock != -1) | ||
close(nxlink_sock); | ||
socketExit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
void switch_enable_network(); | ||
void switch_disable_network(); |