Skip to content

Instantly share code, notes, and snippets.

@jiahuang
Created September 4, 2013 17:33
Show Gist options
  • Save jiahuang/6440159 to your computer and use it in GitHub Desktop.
Save jiahuang/6440159 to your computer and use it in GitHub Desktop.
var board = require('tessel');
var net = board.net;

console.log('opening tcp socket');

console.log('connecting to', process.env.DEPLOY_IP);
var client = net.connect(3000, process.env.DEPLOY_IP, function () {
  console.log('writing');
  
  var body = "name=" + name + "&status=" + status;
  client.write("POST / HTTP/1.1\r\nAccept: *\/*\r\nContent-Length: " + body.length + "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n" + body);
  client.close();
});

client.on('data', function (buf) {
  console.log(buf.red);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment