Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4245)

Unified Diff: chrome/common/extensions/docs/server2/templates/articles/app_network.html

Issue 10908045: Added intro to socket API reference docs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/templates/intros/socket.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/templates/articles/app_network.html
diff --git a/chrome/common/extensions/docs/server2/templates/articles/app_network.html b/chrome/common/extensions/docs/server2/templates/articles/app_network.html
index 7a81cf9659942d1654271b9040694ae741de0c1f..f0c78e12ab3c6ace5297cb0b342f0cf6896aab94 100644
--- a/chrome/common/extensions/docs/server2/templates/articles/app_network.html
+++ b/chrome/common/extensions/docs/server2/templates/articles/app_network.html
@@ -1,6 +1,5 @@
<h1>Network Communications</h1>
-
<p>
Packaged apps can act as a network client
for TCP and UDP connections.
@@ -8,7 +7,7 @@ This doc shows you how to use TCP and UDP
to send and receive data over the network.
For more information,
see the
-<a href="experimental.socket.html">Sockets API</a>.
+<a href="socket.html">Sockets API</a>.
</p>
<p class="note">
@@ -23,17 +22,48 @@ and <a href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/udp"
<p>
For packaged apps that use TCP or UDP,
-add the "experimental" and "socket" permissions
-to the manifest:
+add the "socket" permission to the manifest
+and specify the IP end point permission rules.
+For example:
</p>
<pre>
"permissions": [
- "experimental",
- "socket"
- ]
+ {"socket": [
+ "rule1",
+ "rule2",
+ ...
+ ]}
+ ]
</pre>
+<p>
+The syntax of socket permission rules follows these patterns:
+</p>
+
+<pre>
+&lt;socket-permission-rule>
+ := &lt;op> | &lt;op> ':' &lt;host> | &lt;op> ':' ':' &lt;port> |
+ &lt;op> ':' &lt;host> ':' &lt;port>
+ &lt;op> := 'tcp-connect' | 'tcp-listen' | 'udp-bind' | 'udp-send-to'
+ &lt;host> := '*' | '*.' &lt;anychar except '/' and '*'>+
+ &lt;port> := '*' | &lt;port number between 1 and 65535>)
+</pre>
+
+<p>
+Examples of socket permission rules:
+</p>
+
+<ul>
+ <li>"tcp-connect:*:23" &ndash; For connecting port 23 of any hosts</li>
miket_OOO 2012/08/31 22:33:59 connecting to (or maybe on)
mkearney1 2012/08/31 23:32:12 Done.
+ <li>"tcp-connect:www.example.com:23" &ndash;
+ For connecting port 23 of <em>www.example.com</em></li>
miket_OOO 2012/08/31 22:33:59 Overall I'd eliminate the "for" from each of these
mkearney1 2012/08/31 23:32:12 Done.
+ <li>"tcp-connect" &ndash; For connecting any ports of any hosts</li>
+ <li>"udp-send-to::99" &ndash; For sending UDP package to port 99 of any hosts</li>
miket_OOO 2012/08/31 22:33:59 packet, not package, and I'd say "sending UDP pack
mkearney1 2012/08/31 23:32:12 Done.
+ <li>"udp-bind::8899" &ndash; For binding local port 8899 to receive UDP package</li>
+ <li>"tcp-listen::8080" &ndash; For tcp listening on local port 8080</li>
miket_OOO 2012/08/31 22:33:59 TCP
mkearney1 2012/08/31 23:32:12 Done.
+</ul>
+
<h2 id="tcp">Using TCP</h2>
<p>
@@ -61,7 +91,7 @@ you can later read and write to this socket.
chrome.socket.write(socketId, arrayBuffer, onWriteCompleteCallback);
</pre>
-<h3>Reading to and writing from a socket</h3>
+<h3>Reading to & writing from a socket</h3>
<p>
Reading and writing from a socket uses ArrayBuffer objects.
@@ -96,13 +126,13 @@ over the network using UDP:
<pre>
// Create the Socket
-chrome.experimental.socket.create('udp', '127.0.0.1', 1337, {},
+chrome.socket.create('udp', '127.0.0.1', 1337, {},
function(socketInfo) {
// The socket is created, now we want to connect to the service
var socketId = socketInfo.socketId;
- chrome.experimental.socket.connect(socketId, function(result) {
+ chrome.socket.connect(socketId, function(result) {
// We are now connected to the socket so send it some data
- chrome.experimental.socket.write(socketId, arrayBuffer,
+ chrome.socket.write(socketId, arrayBuffer,
function(sendInfo) {
console.log("wrote " + sendInfo.bytesWritten);
}
@@ -125,18 +155,18 @@ that will be called when data is available on the port.
<pre>
// Handle the data response
var handleDataEvent = function(d) {
- var data = chrome.experimental.socket.read(d.socketId);
+ var data = chrome.socket.read(d.socketId);
console.log(data);
};
// Create the Socket
-chrome.experimental.socket.create('udp', '127.0.0.1', 1337, { onEvent: handleDataEvent },
+chrome.socket.create('udp', '127.0.0.1', 1337, { onEvent: handleDataEvent },
function(socketInfo) {
// The socket is created, now we want to connect to the service
var socketId = socketInfo.socketId;
- chrome.experimental.socket.connect(socketId, function(result) {
+ chrome.socket.connect(socketId, function(result) {
// We are now connected to the socket so send it some data
- chrome.experimental.socket.write(socketId, arrayBuffer,
+ chrome.socket.write(socketId, arrayBuffer,
function(sendInfo) {
console.log("wrote " + sendInfo.bytesWritten);
}
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/templates/intros/socket.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698