Question

Will be a support of raw sockets in node.js, e.g. to create ping packets?

Was it helpful?

Solution

A new module named node-raw-socket offers the perfect solution for real raw sockets using nodejs.

And, for creating ping (ICMP) packets, the same developer has a very nice working (using it) solution based on node-raw-sockets as well: node-net-ping.

OTHER TIPS

Node supports TCP, UDP, and unix sockets. Ping packets are ICMP packets, which node cannot create directly at this time. You could execute an external ping subprocess or consider writing a C extension. Most of node's low level OS APIs are thin javascript wrappers around the corresponding C API, so you could follow that existing well-established pattern and implement this as a small JS wrapper layer around the corresponding OS-level APIs.

http://nodejs.org/docs/latest/api/all.html#all_class_net_socket

There's a chance node/javascript are a poor choice for your project based on this requirement though.

net-ping module may suit your need. to install it you can use the following command:

npm install net-ping

The documentation with examples is included here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top