mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-23 03:02:04 +00:00
Move socket_nonblock to netplay_compat.c
This commit is contained in:
parent
78f3d554be
commit
4cb34282c5
10
command.c
10
command.c
@ -52,16 +52,6 @@ struct rarch_cmd
|
||||
bool state[RARCH_BIND_LIST_END];
|
||||
};
|
||||
|
||||
static bool socket_nonblock(int fd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
u_long mode = 1;
|
||||
return ioctlsocket(fd, FIONBIO, &mode) == 0;
|
||||
#else
|
||||
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)
|
||||
static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port)
|
||||
{
|
||||
|
16
net_http.c
16
net_http.c
@ -18,7 +18,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include "netplay_compat.h"
|
||||
|
||||
enum
|
||||
@ -117,16 +116,11 @@ static int net_http_new_socket(const char * domain, int port)
|
||||
|
||||
freeaddrinfo_rarch(addr);
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
|
||||
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
|
||||
#elif defined(_WIN32)
|
||||
ioctlsocket(fd, FIONBIO, &mode);
|
||||
#else
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
if (!socket_nonblock(fd))
|
||||
{
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
@ -83,3 +83,18 @@ void freeaddrinfo_rarch(struct addrinfo *res)
|
||||
freeaddrinfo(res);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool socket_nonblock(int fd)
|
||||
{
|
||||
#if defined(__CELLOS_LV2__)
|
||||
int i = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
|
||||
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
|
||||
return true;
|
||||
#elif defined(_WIN32)
|
||||
u_long mode = 1;
|
||||
return ioctlsocket(fd, FIONBIO, &mode) == 0;
|
||||
#else
|
||||
return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
@ -129,5 +131,8 @@ int getaddrinfo_rarch(const char *node, const char *service,
|
||||
struct addrinfo **res);
|
||||
|
||||
void freeaddrinfo_rarch(struct addrinfo *res);
|
||||
|
||||
bool socket_nonblock(int fd);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user