Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for slow tcp connect in non blocking mode #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tdev
Copy link

@tdev tdev commented Sep 19, 2016

Hotfix for nonblocking, slow TCP connections not returning instantly. If the connect() takes too long, it will return WSAEALREADY, which when linked incorrectly, return WSAINVAL instead. This will destroy the connection.

Quote from: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737625(v=vs.85).aspx

WSAEALREADY: A nonblocking connect call is in progress on the specified socket.
Note In order to preserve backward compatibility, this error is reported as WSAEINVAL to Windows
Sockets 1.1 applications that link to either Winsock.dll or Wsock32.dll."

The attached patch converts any WSAINVAL to WSAEALREADY. This has the problem, that if you really have invalid arguments (call connect on a listening socket) it will not fatally fail anymore.

@ewestbrook
Copy link
Contributor

Can this be done without breaking the listening socket error case?

In other words, can we test whether it's a listening socket and only convert WSAINVAL to WSAEALREADY when it's not?

If we can't test for that, should we make note of it when socket_listen is called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants