made with requirebin
Last active
September 10, 2015 20:13
-
-
Save edrex/9a68bf01d833f26cf9aa to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // require() some stuff from npm (like you were using browserify) | |
| // and then hit Run Code to run it on the right | |
| var net = require('net'); | |
| var socket = net.connect({ | |
| host: 'localhost', | |
| port: 64080 | |
| }); | |
| socket.on('error', function (err) { | |
| console.error(err); | |
| }); | |
| socket.on('connect', function () { | |
| console.log('Connected!'); | |
| }); | |
| socket.on('data', function (buffer) { | |
| document.getElementById('output').innerHTML += buffer.toString(); | |
| }); | |
| socket.on('end', function () { | |
| console.log('Socket closed.'); | |
| }); | |
| var ending = '\r\n'; | |
| var reqStr = 'GET /'+ending+'Host: google.com'+ending+ending; | |
| document.getElementById('input').innerHTML = reqStr; | |
| socket.write(reqStr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({net:[function(require,module,exports){},{}]},{},[]);var net=require("net");var socket=net.connect({host:"localhost",port:64080});socket.on("error",function(err){console.error(err)});socket.on("connect",function(){console.log("Connected!")});socket.on("data",function(buffer){document.getElementById("output").innerHTML+=buffer.toString()});socket.on("end",function(){console.log("Socket closed.")});var ending="\r\n";var reqStr="GET /"+ending+"Host: google.com"+ending+ending;document.getElementById("input").innerHTML=reqStr;socket.write(reqStr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "requirebin-sketch", | |
| "version": "1.0.0", | |
| "dependencies": {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="output"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment