We are developing a WebSocket server using Nodejs with socket.io
I have used createServer method from class HTTP and then listen to a port as follows :
var server = http.createServer();
server.listen(port, function () {
...
}
Now The problem is that I only have the service name and listening to a service doesn't work :
var server = http.createServer();
server.listen(service, function () {
...
}
So I need to read and parse the file /etc/services to get the port associated with the service as follows :
var str = fs.readFileSync(filename).toString();
var serviceline = str.match( port+".*tcp" );
var port = serviceline[0].match( "[0-9]+" )
Is there a simpler way to get the port from the service?
Thanks in advance
Jean-Marie