mirror of
https://github.com/godotengine/godot
synced 2024-11-02 14:43:31 +00:00
Use WSAConnect instead of connect on Windows.
The misterious windows networking stack... Using connect instead of WSAConnect causes socket error 10022 under certain conditions. See: https://github.com/godotengine/webrtc-native/ (issue 6) Having to guess, code path for connect is different then WSAConnect with NULL extra parameters. The only reference about weird error with this code mentions something called "Windows Filtering Platform" but windows internals are, as always, obscure. This might be something to try and report to Microsoft if anyone has the time to spare with the likely outcome of being ignored.
This commit is contained in:
parent
6ce35e176f
commit
d780570faf
1 changed files with 5 additions and 1 deletions
|
@ -70,6 +70,7 @@
|
|||
#define SOCK_CBUF(x) x
|
||||
#define SOCK_IOCTL ioctl
|
||||
#define SOCK_CLOSE ::close
|
||||
#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::connect(p_sock, p_addr, p_addr_len)
|
||||
|
||||
/* Windows */
|
||||
#elif defined(WINDOWS_ENABLED)
|
||||
|
@ -83,6 +84,9 @@
|
|||
#define SOCK_CBUF(x) (const char *)(x)
|
||||
#define SOCK_IOCTL ioctlsocket
|
||||
#define SOCK_CLOSE closesocket
|
||||
// connect is broken on windows under certain conditions, reasons unknown:
|
||||
// See https://github.com/godotengine/webrtc-native/issues/6
|
||||
#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::WSAConnect(p_sock, p_addr, p_addr_len, NULL, NULL, NULL, NULL)
|
||||
|
||||
// Workaround missing flag in MinGW
|
||||
#if defined(__MINGW32__) && !defined(SIO_UDP_NETRESET)
|
||||
|
@ -409,7 +413,7 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
|
|||
struct sockaddr_storage addr;
|
||||
size_t addr_size = _set_addr_storage(&addr, p_host, p_port, _ip_type);
|
||||
|
||||
if (::connect(_sock, (struct sockaddr *)&addr, addr_size) != 0) {
|
||||
if (SOCK_CONNECT(_sock, (struct sockaddr *)&addr, addr_size) != 0) {
|
||||
|
||||
NetError err = _get_socket_error();
|
||||
|
||||
|
|
Loading…
Reference in a new issue