OLD | NEW |
1 <h1>Network Communications</h1> | 1 <h1>Network Communications</h1> |
2 | 2 |
3 <p> | 3 <p> |
4 Chrome Apps can act as a network client | 4 Chrome Apps can act as a network client |
5 for TCP and UDP connections. | 5 for TCP and UDP connections. |
6 This doc shows you how to use TCP and UDP | 6 This doc shows you how to use TCP and UDP |
7 to send and receive data over the network. | 7 to send and receive data over the network. |
8 For more information, | 8 For more information, |
9 see the | 9 see the |
10 <a href="sockets_udp.html">Sockets UDP</a>, | 10 <a href="sockets_udp">Sockets UDP</a>, |
11 <a href="sockets_tcp.html">Sockets TCP</a> and | 11 <a href="sockets_tcp">Sockets TCP</a> and |
12 <a href="sockets_tcp_server.html">Sockets TCP Server</a> APIs. | 12 <a href="sockets_tcp_server">Sockets TCP Server</a> APIs. |
13 </p> | 13 </p> |
14 | 14 |
15 <p class="note"> | 15 <p class="note"> |
16 <b>Note: </b>The previous version of the networking APIs ($(ref:socket)) has bee
n | 16 <b>Note: </b>The previous version of the networking APIs ($(ref:socket)) has bee
n |
17 deprecated. | 17 deprecated. |
18 </p> | 18 </p> |
19 <p></p> | 19 <p></p> |
20 <p class="note"> | 20 <p class="note"> |
21 <b>API Samples: </b> | 21 <b>API Samples: </b> |
22 Want to play with the code? | 22 Want to play with the code? |
23 Check out the | 23 Check out the |
24 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/telnet">
telnet</a> | 24 <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/telnet">
telnet</a> |
25 and <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/udp"
>udp</a> samples. | 25 and <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/udp"
>udp</a> samples. |
26 </p> | 26 </p> |
27 | 27 |
28 <h2 id="manifest">Manifest requirements</h2> | 28 <h2 id="manifest">Manifest requirements</h2> |
29 | 29 |
30 <p> | 30 <p> |
31 For Chrome Apps that use TCP or UDP, | 31 For Chrome Apps that use TCP or UDP, |
32 add the <a href="manifest/sockets.html">sockets</a> entry to the manifest | 32 add the <a href="manifest/sockets">sockets</a> entry to the manifest |
33 and specify the IP end point permission rules. | 33 and specify the IP end point permission rules. |
34 For example: | 34 For example: |
35 </p> | 35 </p> |
36 | 36 |
37 <pre data-filename="manifest.json"> | 37 <pre data-filename="manifest.json"> |
38 "sockets": { | 38 "sockets": { |
39 "udp": { | 39 "udp": { |
40 "send": ["host-pattern1", ...], | 40 "send": ["host-pattern1", ...], |
41 "bind": ["host-pattern2", ...], | 41 "bind": ["host-pattern2", ...], |
42 ... | 42 ... |
(...skipping 13 matching lines...) Expand all Loading... |
56 The syntax of socket "host-pattern" entries follows these rules: | 56 The syntax of socket "host-pattern" entries follows these rules: |
57 </p> | 57 </p> |
58 | 58 |
59 <pre> | 59 <pre> |
60 <host-pattern> := <host> | ':' <port> | <host> ':' <port> | 60 <host-pattern> := <host> | ':' <port> | <host> ':' <port> |
61 <host> := '*' | '*.' <anychar except '/' and '*'>+ | 61 <host> := '*' | '*.' <anychar except '/' and '*'>+ |
62 <port> := '*' | <port number between 1 and 65535>) | 62 <port> := '*' | <port number between 1 and 65535>) |
63 </pre> | 63 </pre> |
64 | 64 |
65 <p> | 65 <p> |
66 See <a href="manifest/sockets.html">Sockets Manifest Key</a> for detailed | 66 See <a href="manifest/sockets">Sockets Manifest Key</a> for detailed |
67 description of the syntax. | 67 description of the syntax. |
68 </p> | 68 </p> |
69 | 69 |
70 <p> | 70 <p> |
71 Examples of socket manifest entries: | 71 Examples of socket manifest entries: |
72 </p> | 72 </p> |
73 | 73 |
74 <ul> | 74 <ul> |
75 <li><code>{ "tcp": { "connect" : "*:23" } }</code> – connecting on | 75 <li><code>{ "tcp": { "connect" : "*:23" } }</code> – connecting on |
76 port 23 of any hosts</li> | 76 port 23 of any hosts</li> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Call $(ref:sockets.tcp.disconnect) on the server socket ID to stop accepting | 286 Call $(ref:sockets.tcp.disconnect) on the server socket ID to stop accepting |
287 new connections. | 287 new connections. |
288 </p> | 288 </p> |
289 | 289 |
290 <pre> | 290 <pre> |
291 chrome.sockets.tcpServer.onAccept.removeListener(onAccept); | 291 chrome.sockets.tcpServer.onAccept.removeListener(onAccept); |
292 chrome.sockets.tcpServer.disconnect(serverSocketId);</pre> | 292 chrome.sockets.tcpServer.disconnect(serverSocketId);</pre> |
293 | 293 |
294 | 294 |
295 <p class="backtotop"><a href="#top">Back to top</a></p> | 295 <p class="backtotop"><a href="#top">Back to top</a></p> |
OLD | NEW |