套接字

sockets 清单属性声明哪些权限可用于 sockets.udpsockets.tcpsockets.tcpServer API。

manifest.json 示例

{
  "name": "My Sockets app",
  "sockets": {
    "udp": {
      // Permission for chrome.sockets.udp.send:
      // The application is allowed to send udp packets
      // to any host:port combination.
      "send": "*"
    },
    "tcp": {
      // Permission for chrome.sockets.tcp.connect:
      // The application is allowed to connect only to the
      // tcp server on 127.0.0.1 port 80.
      "connect": "127.0.0.1:80"
    },
    "tcpServer": {
      // Permission for chrome.sockets.tcpServer.listen:
      // The application is allowed to accept new client
      // connections on the local address at port 80.
      "listen": "127.0.0.1:80"
    }
  },
  ...
}

参考

  • udp(对象)- 可选

    udp 清单属性声明了应用可以发出哪些 sockets.udp 操作。

    类型属性说明
    字符串或字符串数组(可选)绑定

    bind 操作的 host:port 模式。

    字符串或字符串数组(可选)发送

    send 操作的 host:port 模式。

    字符串或字符串数组(可选)multicastMembership

    joinGroup 操作的 host:port 模式。

  • tcp(对象)- 可选

    tcp 清单属性声明了应用可以发出哪些 sockets.tcp 操作。

    类型属性说明
    字符串或字符串数组(可选)连接

    connect 操作的 host:port 模式。

  • tcpServer(对象)- 可选

    tcpServer 清单属性声明了应用可以发出哪些 sockets.tcpServer 操作。

    类型属性说明
    字符串或字符串数组(可选)收听

    listen 操作的 host:port 模式。