title: Google Chrome Extension Using With UDP
body: <p>I want to develope basic extension. This extension should communicate on UDP. This extension is about messaging. I want to create a client. Because i create a server in Java. Client can sent message to server and server can message to client.</p>
  
  <p>I look at <a href="https://developer.chrome.com/extensions/devguide" rel="nofollow noreferrer">Chrome Developer</a> page. But these documents are not up to date. I create a basic client like this:</p>
  
  <pre><code>// values
  var address     = null;
  var connect     = null;
  var disconnect  = null;
  
  // UDP-Object
  var echoClient  = null;
  
  // -------------------------------------------------------------------------------------------------------------------
  
  window.addEventListener("load", function() {
  
    // input: address.val
    address = document.getElementById("address");
  
    // button: connect.val
    connect = document.getElementById("connect");
  
    // button: disconnect.val
    disconnect = document.getElementById("disconnect");
  
    // button: connect.func
    connect.onclick = function(ev) {
      if(address.value != ""){
        echoClient = newEchoClient(address.value);
      }
    };
  
    // button: disconnect.func
    disconnect.onclick = function(ev) {
      echoClient.disconnect();
    }
  
    // send data
    setInterval(function(){ 
      echoClient.sender();
    }, 1000);
  
  });
  
  // -------------------------------------------------------------------------------------------------------------------
  
  var newEchoClient = function(address) {
    var ec            = new chromeNetworking.clients.echoClient();
    ec.sender         = attachSend(ec);
    var hostnamePort  = address.split(":");
    var hostname      = hostnamePort[0];
    var port          = (hostnamePort[1] || 7) | 0;
    ec.connect(
      hostname, port,
      function() {
        console.log("Connected");
      }
    );
    return ec;
  };
  
  var attachSend = function(client) {
    var i = 1;
    return function(e) {
      var data = i;
      i++;
      client.echo(data, function() {
          console.debug(data.data); // the problem is here
      });
    };
  };
  </code></pre>
  
  <p>But this code is not working. In the Chrome i took this error:</p>
  
  <pre><code>Error in event handler for sockets.udp.onReceive: RangeError: byte length of Uint32Array should be a multiple of 4
      at chrome-extension://boeaihphlidceiemkegklmbmefjgogfk/networking.js:84:25
      at chrome-extension://boeaihphlidceiemkegklmbmefjgogfk/networking.js:31:34
  </code></pre>
  
  <p>Where is wrong? What i do about this problem?</p>