title: Socket not connected error when using chrome.sockets.udp
body: <p>I tried to run the following code as an unpacked chrome extension and got the following output in my console:</p>
  
  <pre><code>clicked
  sent undefined
  Error listening: net::ERR_SOCKET_NOT_CONNECTED
  </code></pre>
  
  <p>I am also using a separate software to create a UDP server on port 11111 and it receives nothing.</p>
  
  <p><strong>manifest.json</strong></p>
  
  <pre><code>{
      "name": "UDP Test",
      "description": "Testing UDP connection.",
      "version": "0.1",
      "app": {
          "background": {
              "scripts": ["background.js"]
           }
      },
      "minimum_chrome_version": "33",
      "sockets": {
          "udp": {
              "send": "*"
          }
      }
  }
  </code></pre>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>// On app launch
  chrome.app.runtime.onLaunched.addListener(function() {
      // Create window
      chrome.app.window.create('window.html', {
          'bounds': {
              'width': 400,
              'height': 500
          }
      });
  });
  </code></pre>
  
  <p><strong>window.html</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;button id="test"&gt;Run&lt;/button&gt;
          &lt;script src="network.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>network.js</strong></p>
  
  <pre><code>test.addEventListener('click', function() {
      console.log("clicked");
      chrome.sockets.udp.create({}, function (socketInfo) {
          // The socket is created, now we can send some data
          var socketId = socketInfo.socketId;
          var arrayBuffer = stringToArrayBuffer("hello");
          chrome.sockets.udp.send(socketId, stringToArrayBuffer("hello"), "127.0.0.1", 11111, function(sendInfo) {
              console.log("sent " + sendInfo.bytesSent);
              if (sendInfo.resultCode &lt; 0) {
                  console.log("Error listening: " + chrome.runtime.lastError.message);
              }
          });
      });
  });
  
  function stringToArrayBuffer(string) {
      var buffer = new ArrayBuffer(string.length * 2);
      var bufferView = new Uint16Array(buffer);
      for (var i = 0, stringLength = string.length; i &lt; stringLength; i++) {
          bufferView = string.charCodeAt(i);
      }
      return buffer;
  }
  </code></pre>
  
  <p>Any ideas why this is happening? I have found several examples of chrome udp but they all used the experimental APIs and not this one. </p>