Tcp start server to run Chrome applications

I tried to start a simple tcp server:

chrome.sockets.tcpServer.create({}, function(info){
    chrome.sockets.tcpServer.listen(info.socketId, 'localhost', 2000, function(result){
        console.log(result);
    });
});

But somehow it console.log(result);always displays undefined!

http://developer.chrome.com/apps/sockets_tcpServer#method-create

http://developer.chrome.com/apps/sockets_tcpServer#method-listen

What am I wrong? Thank!

+4
source share
1 answer

For your manifest, you must add the following permission:

"sockets": {
  "tcpServer" : {
    "listen": ["host-pattern1", ...],
    ...
  }
}

https://developer.chrome.com/apps/app_network

+1
source

Source: https://habr.com/ru/post/1531034/


All Articles