Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome app start tcp server

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 console.log(result); always prints out undefined!

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

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

What do i wrong? Thanks!

like image 519
John Smith Avatar asked Nov 10 '22 11:11

John Smith


1 Answers

You have to add the following permission to your manifest :

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

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

like image 110
Co_42 Avatar answered Nov 15 '22 12:11

Co_42