title: Cordova chrome.socket API. Any example?
body: <p>I am trying to use org.chromium.socket plugin. But I cannot find many examples. Here is my code:</p>
  
  <pre><code>var connButton = document.getElementById("connButton");
  
  connButton.addEventListener("click", doConnect, false);
  
  function doConnect() {
      var theSocketId = 0;
      chrome.socket.create("tcp", null, function(createInfo) {
          alert(createInfo.socketId);
          theSocketId = createInfo.socketId;
       });
       chrome.socket.connect(theSocketId, "http://www.yahoo.com", 80, function(result) {
          alert(result);
       });
  chrome.socket.read(theSocketId, 1000, function(readInfo) {
        alert(readInfo.resultCode);
    });
    }
  </code></pre>
  
  <p>I try to change the host name to different IP or change the port. But sometime I see result = -1000, which indicates failure. Or sometime I cannot see result alert. I also have problem using chrome.socket.read.</p>
  
  <p>Please critique my code. Thank you very much!</p>