I've been working with node.js for the past couple of weeks and I need to implement the FAST-CGI protocol. The problem is that when I create a UNIX socket (via "new Socket") I need to get the filename, or file descriptor. But socket.fd is null (default parameter).
My question is: Does "new Socket" creates a operating system socket object file, and if so, how can I get the Socket File Descriptor or File Name?
I'm not sure if this is how I should create a Socket, but here is the case:
node:
var net = require(net)
var socket = new net.Socket()
console.log(socket);
{
bufferSize: 0,
fd:null,
type: null,
allowHalfOpen: false,
_writeImpl: [Function],
_readImpl: [Function],
_shutdownImpl: [Function]
}
Web Socket is a protocol that provides full-duplex(multiway) communication i.e allows communication in both directions simultaneously. It is a modern web technology in which there is a continuous connection between the user's browser(client) and the server.
All we need to do is call the WebSocket Object with a URI as the parameter. const webSocket = new WebSocket('ws://localhost:443/'); And then we can create an event for the WebSocket to do something when it gets data. That's it we can now receive data from the WebSocket server.
The node:net module provides an asynchronous network API for creating stream-based TCP or IPC servers ( net. createServer() ) and clients ( net.
The Node. js Client uses the MarkLogic REST Client API to communicate with MarkLogic Server, so it uses the same security model.
Well when you connect a socket, socket.fd is not null, at least not in my case, so provide an example case please.
Note that you can also specify existing file descriptor at socket creation.
Edit:
var net = require('net'),
fs = require('fs'),
sock;
// Create socket file
fs.open('/tmp/node.test.sock', 'w+', function(err, fdesc){
if (err || !fdesc) {
throw 'Error: ' + (err || 'No fdesc');
}
// Create socket
sock = new net.Socket({ fd : fdesc });
console.log(sock);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With