mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-30 14:53:39 +00:00
Some code de-duplication
This commit is contained in:
parent
00a49d068e
commit
b25b2a0e6c
@ -505,11 +505,6 @@ static bool send_udp_packet(const char *host,
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
|
|
||||||
hints.ai_family = AF_INET;
|
|
||||||
#else
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
#endif
|
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port);
|
snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port);
|
||||||
|
@ -107,10 +107,16 @@ int getaddrinfo_retro(const char *node, const char *service,
|
|||||||
if (!info)
|
if (!info)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
info->ai_family = AF_INET;
|
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
|
||||||
info->ai_socktype = hints->ai_socktype;
|
hints->ai_family = AF_INET;
|
||||||
|
#else
|
||||||
|
hints->ai_family = AF_UNSPEC;
|
||||||
|
#endif
|
||||||
|
|
||||||
in_addr = (struct sockaddr_in*)calloc(1, sizeof(*in_addr));
|
info->ai_family = AF_INET;
|
||||||
|
info->ai_socktype = hints->ai_socktype;
|
||||||
|
in_addr = (struct sockaddr_in*)
|
||||||
|
calloc(1, sizeof(*in_addr));
|
||||||
|
|
||||||
if (!in_addr)
|
if (!in_addr)
|
||||||
goto error;
|
goto error;
|
||||||
@ -136,7 +142,7 @@ int getaddrinfo_retro(const char *node, const char *service,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
info->ai_addr = (struct sockaddr*)in_addr;
|
info->ai_addr = (struct sockaddr*)in_addr;
|
||||||
*res = info;
|
*res = info;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -31,16 +31,9 @@ int socket_init(void **address, uint16_t port, const char *server, enum socket_t
|
|||||||
struct addrinfo **addrinfo = (struct addrinfo**)address;
|
struct addrinfo **addrinfo = (struct addrinfo**)address;
|
||||||
struct addrinfo *addr = NULL;
|
struct addrinfo *addr = NULL;
|
||||||
|
|
||||||
|
|
||||||
if (!network_init())
|
if (!network_init())
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
|
|
||||||
hints.ai_family = AF_INET;
|
|
||||||
#else
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SOCKET_TYPE_DATAGRAM:
|
case SOCKET_TYPE_DATAGRAM:
|
||||||
|
@ -707,12 +707,6 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server,
|
|||||||
struct addrinfo *res = NULL;
|
struct addrinfo *res = NULL;
|
||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
|
|
||||||
hints.ai_family = AF_INET;
|
|
||||||
#else
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
if (!server)
|
if (!server)
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
Loading…
Reference in New Issue
Block a user