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

Don't pass sockets into HttpServer #110

Open
ghost opened this issue Jul 1, 2011 · 2 comments
Open

Don't pass sockets into HttpServer #110

ghost opened this issue Jul 1, 2011 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 1, 2011

Create them from context instead.

@ghost ghost self-assigned this Jul 1, 2011
@txdv
Copy link
Contributor

txdv commented Jul 6, 2011

I gave it a thought and passing the socket is a valuable idea.

By passing the sockets you can force HttpServer to use special sockets, for example SslSocket.
Since HttpServer uses only Listen, maybe passing it in the constructor is the best way to go.

I was just confused when creating an IrcClient class, because I just went with what I have already seen (socket in the constructor), but the IrcClient doesn't listen on any port, actually it has to connect to various other sources and recreate the socket if the connection fails or can't be completed.

But still, IrcClients can use ssl and socks4 to communicate:
in order to use different functionality, i need to provide the socket in the constructor,
but on the other hand I can't do, because I have to recreate the socket.

One possible solution to solve this dilema is to make sockets reusable, what do you think myeisha?
I can probably come up with some delegate based API, but it would look ugly as far as I can tell.

@ghost
Copy link
Author

ghost commented Jul 6, 2011

Yeah, no. The idea behind the current IO architecture was to have simple base functionality, and a pipeline that wraps more and more around it. For SSL, you'd hook into the pipeline at ClientConnected and wrap the stream in a TlsStream.

Same or similar things work for other protocols. In the IRC example, you wouldn't even need that, because the IRC client would be happy with only a stream it can work with. You would then have static factory methods that connect to foreign servers via different transport types.

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

1 participant