Dong Liu
Dong Liu

Reputation: 11

Is there a kind of "Socket connection pool" in nodejs?

In order to avoid the time spent on the creation of the sockets. My node server need some "long connection"(TCP Socket) to keep communicating with the server written in C which runs in the background, and all the 'http request' could share the TCP sockets in the pool. I wonder if there is a kind of socket pool implementation in nodejs? (something like the database connection pool)

Any help will be appreciated !

Upvotes: 1

Views: 4721

Answers (2)

不辞长做岭南人
不辞长做岭南人

Reputation: 481

generic pool is a good one. https://github.com/coopernurse/node-pool But as for http, there's built-in pooling mechanism .

Upvotes: 4

ebohlman
ebohlman

Reputation: 15003

Take a look at the official documentation for http.Agent; that's what (behind the scenes for most node developers) handles allocation of available sockets.

Upvotes: 0

Related Questions