Avoid altering TCP sockets
Co-authored-by: sepalani <sepalani@hotmail.fr>
This commit is contained in:
parent
301e97f7f7
commit
078730c873
|
@ -873,8 +873,25 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
|||
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
|
||||
#endif
|
||||
|
||||
int opt_broadcast = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char*)&opt_broadcast, sizeof(opt_broadcast));
|
||||
// Wii UDP sockets can use broadcast address by default
|
||||
if (!is_rw)
|
||||
{
|
||||
const auto state = Common::SaveNetworkErrorState();
|
||||
Common::ScopeGuard guard([&state] { Common::RestoreNetworkErrorState(state); });
|
||||
|
||||
int socket_type;
|
||||
socklen_t option_length = sizeof(socket_type);
|
||||
const bool is_udp = getsockopt(fd, SOL_SOCKET, SO_TYPE, reinterpret_cast<char*>(&socket_type),
|
||||
&option_length) == 0 &&
|
||||
socket_type == SOCK_DGRAM;
|
||||
const int opt_broadcast = 1;
|
||||
if (is_udp &&
|
||||
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>(&opt_broadcast),
|
||||
sizeof(opt_broadcast)) != 0)
|
||||
{
|
||||
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_BROADCAST on socket");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetLastNetError(wii_fd);
|
||||
|
|
Loading…
Reference in New Issue