 
   console.info("CLIENT: SEND: hello world")
   stream.write("hello world")
+  stream.write("hello world2")
   stream.setEncoding("utf-8")
   stream.on "data", (data) ->
     console.info("CLIENT: RECV: #{data}")

  readyForWriting = false
  encoding = null
  emitter = new EventEmitter()
  stream =
    readable: true
    writeable: true

    setEncoding: (e) ->
      encoding = e
    write: (data) ->
      writeQueue.push ->
        req = http.request {port: phantomServerPort, method: "POST"}, ->
          waitingOnPreviousWrite = false
          doNextWrite()
        req.on "error", (err) ->
          logger.error?(err)
        req.setHeader("Content-Length", data.length)
        req.end(data)
      if readyForWriting
        doNextWrite()
      else
        emitter.on "ready", ->
          readyForWriting = true
          doNextWrite()
  return stream

exports.open = open
