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

Connect asynchronously #19

Open
igorw opened this issue Jan 15, 2013 · 2 comments
Open

Connect asynchronously #19

igorw opened this issue Jan 15, 2013 · 2 comments
Labels

Comments

@igorw
Copy link
Contributor

igorw commented Jan 15, 2013

Currently the connect call itself is blocking.

We should call stream_socket_client with the STREAM_CLIENT_ASYNC_CONNECT flag. But that means we cannot tell connection failure at connect time.

We can only detect connection failure if we have reactphp/reactphp#113. So that needs to be fixed first.

@nrk
Copy link

nrk commented Jan 15, 2013

There's a workaround even without the need for reactphp/react#113: you set the STREAM_CLIENT_ASYNC_CONNECT flag and subscribe for a write event on the connecting stream, if stream_socket_get_name($socket, true) === false when the write event kicks then it means that the connection has been refused.

I do that in Predis\Async and it seems to work quite well, see here and here for the related code.

@igorw
Copy link
Contributor Author

igorw commented Jan 15, 2013

That's quite nice, ideally we would have something for that in react core.

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

No branches or pull requests

2 participants