mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Add socket_type to socket_init
This commit is contained in:
parent
d2a80e26db
commit
8b9456f419
@ -130,7 +130,7 @@ static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port)
|
||||
RARCH_LOG("Bringing up command interface on port %hu.\n",
|
||||
(unsigned short)port);
|
||||
|
||||
if (!socket_init(res, file_desc, port, NULL))
|
||||
if (!socket_init(res, file_desc, port, NULL, SOCKET_TYPE_DATAGRAM))
|
||||
goto error;
|
||||
|
||||
if (*file_desc < 0)
|
||||
|
@ -31,7 +31,13 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
bool socket_init(void *address, int *fd, uint16_t port, const char *server);
|
||||
enum socket_type
|
||||
{
|
||||
SOCKET_TYPE_DATAGRAM = 0,
|
||||
SOCKET_TYPE_STREAM
|
||||
};
|
||||
|
||||
bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type);
|
||||
|
||||
int socket_close(int fd);
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <net/net_compat.h>
|
||||
#include <net/net_socket.h>
|
||||
|
||||
bool socket_init(void *address, int *fd, uint16_t port, const char *server)
|
||||
bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type)
|
||||
{
|
||||
char port_buf[16] = {0};
|
||||
struct addrinfo hints = {0};
|
||||
@ -41,7 +41,16 @@ bool socket_init(void *address, int *fd, uint16_t port, const char *server)
|
||||
#else
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
#endif
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SOCKET_TYPE_DATAGRAM:
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
break;
|
||||
case SOCKET_TYPE_STREAM:
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
break;
|
||||
}
|
||||
if (!server)
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
|
@ -763,7 +763,7 @@ static bool init_udp_socket(netplay_t *netplay, const char *server,
|
||||
uint16_t port)
|
||||
{
|
||||
int *file_desc = (int*)&netplay->udp_fd;
|
||||
if (!socket_init(&netplay->addr, file_desc, port, server))
|
||||
if (!socket_init(&netplay->addr, file_desc, port, server, SOCKET_TYPE_DATAGRAM))
|
||||
return false;
|
||||
|
||||
if (*file_desc < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user