| Index: native_client_sdk/src/libraries/nacl_io_socket_test/example.js
|
| diff --git a/native_client_sdk/src/libraries/nacl_io_test/example.js b/native_client_sdk/src/libraries/nacl_io_socket_test/example.js
|
| similarity index 68%
|
| copy from native_client_sdk/src/libraries/nacl_io_test/example.js
|
| copy to native_client_sdk/src/libraries/nacl_io_socket_test/example.js
|
| index bd175944b9a4deb1ac549ea1daabd4323271be1a..1a6a8bf8683a7150e4bcea680546de6175c2c5bd 100644
|
| --- a/native_client_sdk/src/libraries/nacl_io_test/example.js
|
| +++ b/native_client_sdk/src/libraries/nacl_io_socket_test/example.js
|
| @@ -2,10 +2,51 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
| // Called by the common.js module.
|
| +
|
| +function runTCPEchoServer(port) {
|
| + console.log("Starting server on TCP port: " + port);
|
| + chrome.socket.create("tcp", {}, function(createInfo) {
|
| + var listeningSocket = createInfo.socketId;
|
| + chrome.socket.listen(listeningSocket,
|
| + '127.0.0.1',
|
| + port,
|
| + 10,
|
| + function(result) {
|
| + if (result !== 0) {
|
| + console.log("Listen failed: " + result);
|
| + return;
|
| + }
|
| +
|
| + chrome.socket.accept(listeningSocket, function(acceptInfo) {
|
| + if (result !== 0) {
|
| + console.log("Accept failed: " + result);
|
| + return;
|
| + }
|
| +
|
| + var newSock = acceptInfo.socketId;
|
| +
|
| + var readCallback = function(readInfo) {
|
| + if (readInfo.resultCode < 0) {
|
| + console.log("Read failed: " + readInfo.resultCode);
|
| + chrome.socket.destroy(newSock);
|
| + return;
|
| + }
|
| +
|
| + chrome.socket.write(newSock, readInfo.data, function(writeInfo) {})
|
| + chrome.socket.read(newSock, readCallback);
|
| + }
|
| +
|
| + chrome.socket.read(newSock, readCallback);
|
| + })
|
| + })
|
| + })
|
| +}
|
| +
|
| function moduleDidLoad() {
|
| // The module is not hidden by default so we can easily see if the plugin
|
| // failed to load.
|
| common.hideModule();
|
| + runTCPEchoServer(4006);
|
| }
|
|
|
| var currentTestEl = null;
|
|
|