Create network_init and network_deinit functions

This commit is contained in:
twinaphex 2014-12-21 03:29:52 +01:00
parent 2621ea9dd8
commit 9daecea53e
3 changed files with 18 additions and 7 deletions

View File

@ -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_)))

View File

@ -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
{

View File

@ -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). :) */