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

SocketInitiator and getHost round robin (SocketConnectHost, SocketConnectPort) #418

Closed
pps314159 opened this issue Mar 7, 2023 · 2 comments

Comments

@pps314159
Copy link
Contributor

As far as understand, there can be many connection hosts (SocketConnectHostNNN:SocketConnectPortNNN) and one is picked once connecting. I have got an impression that once getHost is called for a session, it is never called again (even if no connection is established yet). Worse, if an IP got from getHost does not exist (is not resolved to any name), it looks like the session never gets connected.
Is this indeed the situation or a kind of my misunderstanding? Is there anything I am missing?

@pps314159
Copy link
Contributor Author

I tried to have any deeper look at the issue and I guess that the following thing happens: SocketInitiator creates a socket and issues a connect request. At this point, it does no bother the validity of the IP/port, success/failure of the connection but simply pass the socket to the SocketMonitor. SocketMonitor uses 'select' to process sockets events. Even if the connection was issued to a nonexistent IP, a write event is fired for such a socket and the SocketMonitor processes. Soon enough, it becomes clear that no connection is established and thus a new connection attempt is taken.
As far as I can see, this works this way indeed but only on Linux. On Windows, 'select' does not fire a write event for such a socket and the session just gets stuck. Looks like a kind of bug, doesn't it?

@leleftheriades
Copy link
Contributor

onconnect will subscribe to both write and exception notifications. if the socket is nonblocking the exceptfd will be called on connect timeout

https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select

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

No branches or pull requests

3 participants