You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
This would minimize object creation when trying to implement socket pooling. For example:
letTCPSocketPool=[];// populate socket poolfor(leti=11;--i;){TCPSocketPool.push(newTCPSocket());}// when a socket it needed, instead of constructing a new object, just call:letsocket=TCPSocketPool.shift();// use socketsocket.connect("127.0.0.1","9001");// ...// send back to pool when donesocket.onclose=function(){TCPSocketPool.push(this);};
This separation of creating the socket and connecting would be more familiar to developers with Unix socket programming backgrounds as well.
The text was updated successfully, but these errors were encountered:
The reason why I chose the design that combines the TCP socket creation and peer connect in the constructor is that this is the design used by Web Sockets and that it is a simple design.
I can understand use cases in which an application reuses an existing connected socket to a certain peer for more data to send to that peer as setting up a new peer connection requires some overhead. However, I am not sure that I understand the benefit of using a pool of empty, unconnected TCP socket objects. Could you elaborate on that?
Changing the API to use a separate method for connect is easy but I need to understand the benefits of doing that, especially as that would make the design different from Web Sockets.
Allowing for a pooling abstraction allows developers to more properly anticipate GC pauses, in general. Specifically, I cannot think of any case where a pool of TCP sockets would be combined with high performance JavaScript that relies on object pools to control GC pauses, but that could just be a lack of imagination on my part.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This would minimize object creation when trying to implement socket pooling. For example:
This separation of creating the socket and connecting would be more familiar to developers with Unix socket programming backgrounds as well.
The text was updated successfully, but these errors were encountered: