John Smith
John Smith

Reputation: 6259

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!

Upvotes: 5

Views: 2698

Answers (1)

Co_42
Co_42

Reputation: 1269

You have to add the following permission to your manifest :

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

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

Upvotes: 1

Related Questions