4 Copyright (c) 2013 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
9 <meta http-equiv=
"Pragma" content=
"no-cache">
10 <meta http-equiv=
"Expires" content=
"-1">
11 <title>{{title}}
</title>
12 <script type=
"text/javascript" src=
"common.js"></script>
13 <script type=
"text/javascript" src=
"example.js"></script>
17 <h2>Status:
<code id=
"statusField">NO-STATUS
</code></h2>
18 <p>The socket example demonstrates how to use the TCP and UDP socket API.
<br>
19 This API is normally only available to packaged apps with the requisite
20 socket permission, but can be enabled for debugging purposes using the
21 <code>--allow-nacl-socket-api=
<hostname
></code> command line
23 First set a server address in the form of 'hostname:port', then push the
24 "Connect" button to establish a connection.
<br>
25 "Send" button sends the message of the text area to the the remote host.
26 Any data received back will be output to the status log.
<br>
27 For example, try connecting to a TCP echo server that will reply with
28 whatever bytes you send, or connect to a web server and send a GET
30 "Close" button closes the connection.
<br>
33 <form id=
"connectForm">
34 <select id=
"connect_type">
35 <option value=
"tcp">TCP
</option>
36 <option value=
"udp">UDP
</option>
38 <input type=
"text" id=
"hostname" size=
"25"
39 value=
"google.com:80">
40 <input type=
"submit" value=
"Connect">
44 <input type=
"text" id=
"message" value=
"GET / HTTP/1.1\n\n" size=
"50">
45 <input type=
"submit" value=
"Send">
48 <button id=
"closeButton">Close
</button>
51 <h2>Create a local server:
</h2>
52 <p>The
"Listen" button can be used create a local TCP or UDP echo server
53 listenting on the port specified. Once started this server can be connected
54 to by entering
<code>localhost:
<port
><br> above.
57 <form id=
"listenForm">
58 <select id=
"listen_type">
59 <option value=
"tcp">TCP
</option>
60 <option value=
"udp">UDP
</option>
63 <input type=
"text" id=
"port" value=
"8080" size=
"6">
64 <input type=
"submit" value=
"Listen">
69 <pre id=
"log" style=
"font-weight: bold"></pre>
70 <div id=
"listener"></div>