(netplay.c) Simplify init_tcp_connection
This commit is contained in:
parent
8ce32e01cd
commit
d4a08d7ec7
|
@ -90,9 +90,7 @@ static void video_frame(const void *data, unsigned width,
|
||||||
|
|
||||||
if (g_extern.filter.filter && data)
|
if (g_extern.filter.filter && data)
|
||||||
{
|
{
|
||||||
unsigned owidth = 0;
|
unsigned owidth = 0, oheight = 0, opitch = 0;
|
||||||
unsigned oheight = 0;
|
|
||||||
unsigned opitch = 0;
|
|
||||||
|
|
||||||
rarch_softfilter_get_output_size(g_extern.filter.filter,
|
rarch_softfilter_get_output_size(g_extern.filter.filter,
|
||||||
&owidth, &oheight, width, height);
|
&owidth, &oheight, width, height);
|
||||||
|
@ -469,7 +467,6 @@ static int16_t input_state(unsigned port, unsigned device,
|
||||||
* input_poll_overlay:
|
* input_poll_overlay:
|
||||||
*
|
*
|
||||||
* Poll pressed buttons/keys on currently active overlay.
|
* Poll pressed buttons/keys on currently active overlay.
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
static inline void input_poll_overlay(void)
|
static inline void input_poll_overlay(void)
|
||||||
{
|
{
|
||||||
|
|
17
netplay.c
17
netplay.c
|
@ -285,30 +285,20 @@ static int init_tcp_connection(const struct addrinfo *res,
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (spectate)
|
|
||||||
{
|
|
||||||
int yes = 1;
|
|
||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
|
|
||||||
|
|
||||||
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 ||
|
|
||||||
listen(fd, MAX_SPECTATORS) < 0)
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
|
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
|
||||||
|
|
||||||
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 ||
|
if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 ||
|
||||||
listen(fd, 1) < 0)
|
listen(fd, spectate ? MAX_SPECTATORS : 1) < 0)
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!spectate)
|
||||||
|
{
|
||||||
int new_fd = accept(fd, other_addr, &addr_size);
|
int new_fd = accept(fd, other_addr, &addr_size);
|
||||||
if (new_fd < 0)
|
if (new_fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -319,6 +309,7 @@ static int init_tcp_connection(const struct addrinfo *res,
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = new_fd;
|
fd = new_fd;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (!ret && fd >= 0)
|
if (!ret && fd >= 0)
|
||||||
|
|
Loading…
Reference in New Issue