fix: fix bind interface (#599)

This commit is contained in:
j3l11234 2022-11-01 04:53:14 +08:00 committed by GitHub
parent 47620db2c4
commit 0e5150318b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -786,8 +786,14 @@ socketio_connectex(struct w32_io* pio, const struct sockaddr* name, int namelen)
if (SOCKET_ERROR == bind(pio->sock, tmp_addr, (int)tmp_addr_len)) {
errno = errno_from_WSALastError();
debug3("connectex - ERROR: bind failed :%d, io:%p", WSAGetLastError(), pio);
return -1;
/*
* When use bind_address or bind_interface, this bind will return WSAEINVAL. But it doesn't matter.
* https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind
*/
if (errno != EINVAL) {
debug3("connectex - ERROR: bind failed :%d, io:%p", WSAGetLastError(), pio);
return -1;
}
}
if (SOCKET_ERROR == WSAIoctl(pio->sock, SIO_GET_EXTENSION_FUNCTION_POINTER,