1<!DOCTYPE html> 2<html> 3<!-- 4Copyright (c) 2013 The Chromium Authors. All rights reserved. 5Use of this source code is governed by a BSD-style license that can be 6found in the LICENSE file. 7--> 8<head> 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> 14</head> 15<body {{attrs}}> 16 <h1>{{title}}</h1> 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 22 flag.<br> 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 29 request.<br> 30 "Close" button closes the connection.<br> 31 </p> 32 33 <form id="connectForm"> 34 <select id="connect_type"> 35 <option value="tcp">TCP</option> 36 <option value="udp">UDP</option> 37 </select> 38 <input type="text" id="hostname" size="25" 39 value="google.com:80"> 40 <input type="submit" value="Connect"> 41 </form> 42 43 <form id="sendForm"> 44 <input type="text" id="message" value="GET / HTTP/1.1\n\n" size="50"> 45 <input type="submit" value="Send"> 46 </form> 47 48 <button id="closeButton">Close</button> 49 50 <div> 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. 55 </p> 56 <p> 57 <form id="listenForm"> 58 <select id="listen_type"> 59 <option value="tcp">TCP</option> 60 <option value="udp">UDP</option> 61 </select> 62 Port: 63 <input type="text" id="port" value="8080" size="6"> 64 <input type="submit" value="Listen"> 65 </form> 66 </p> 67 </div> 68 69 <pre id="log" style="font-weight: bold"></pre> 70 <div id="listener"></div> 71</body> 72</html> 73