Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Creating the socket and connecting should be seperate concepts #52

@nickdesaulniers

Description

@nickdesaulniers

This would minimize object creation when trying to implement socket pooling. For example:

let TCPSocketPool = [];

// populate socket pool
for (let i = 11; --i;) {
  TCPSocketPool.push(new TCPSocket());
}

// when a socket it needed, instead of constructing a new object, just call:
let socket = TCPSocketPool.shift();

// use socket
socket.connect("127.0.0.1", "9001");
// ...

// send back to pool when done
socket.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions