Skip to content

Instantly share code, notes, and snippets.

@assaf
Created January 9, 2011 07:16
Show Gist options
  • Save assaf/771508 to your computer and use it in GitHub Desktop.
Save assaf/771508 to your computer and use it in GitHub Desktop.
Simple test case for the Zombie protocol
z = require("./src/index")
z.listen null, (err)->
console.log "Listening"
console.log err if err
requests =[
"*1\r\n$7\r\nBROWSER",
"*3\r\n$5\r\nVISIT$1\r\n0$20\r\nhttp://labnotes.org/",
"*2\r\n$4\r\nWAIT$1\r\n0"
]
stream = require("net").createConnection(8091, "localhost")
stream.on "data", (data)->
console.log "Response:", data.toString().trim()
if request = requests.shift()
stream.write request
else
stream.end()
stream.setNoDelay true
stream.write requests.shift()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment