diff --git a/command.c b/command.c index 2723d62812..63d616dcce 100644 --- a/command.c +++ b/command.c @@ -67,7 +67,7 @@ static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) struct addrinfo hints, *res = NULL; int yes = 1; - if (!netplay_init_network()) + if (!network_init()) return false; RARCH_LOG("Bringing up command interface on port %hu.\n", @@ -612,7 +612,7 @@ bool network_cmd_send(const char *cmd_) bool old_verbose = g_extern.verbosity; uint16_t port = DEFAULT_NETWORK_CMD_PORT; - if (!netplay_init_network()) + if (!network_init()) return false; if (!(command = strdup(cmd_))) diff --git a/netplay.c b/netplay.c index 4a80c6383d..4a8e6cb654 100644 --- a/netplay.c +++ b/netplay.c @@ -435,7 +435,7 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, } /* Platform specific socket library init. */ -bool netplay_init_network(void) +bool network_init(void) { static bool inited = false; if (inited) @@ -445,7 +445,7 @@ bool netplay_init_network(void) WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { - WSACleanup(); + network_deinit(); return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) @@ -459,9 +459,19 @@ bool netplay_init_network(void) return true; } +void network_deinit(void) +{ +#if defined(_WIN32) + WSACleanup(); +#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + sys_net_finalize_network(); + cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); +#endif +} + static bool init_socket(netplay_t *netplay, const char *server, uint16_t port) { - if (!netplay_init_network()) + if (!network_init()) return false; if (!init_tcp_socket(netplay, server, port, netplay->spectate)) @@ -1561,7 +1571,6 @@ void netplay_post_frame(netplay_t *netplay) #define addrinfo addrinfo_rarch__ -/* Yes, we love shitty implementations, don't we? :( */ #ifdef _XBOX struct hostent { diff --git a/netplay.h b/netplay.h index b0c2d7a0df..3e975d4b53 100644 --- a/netplay.h +++ b/netplay.h @@ -43,7 +43,9 @@ int16_t input_state_spectate_client(unsigned port, unsigned device, typedef struct netplay netplay_t; -bool netplay_init_network(void); +bool network_init(void); + +void network_deinit(void); /* Creates a new netplay handle. A NULL host means we're * hosting (user 1). :) */