 {EventEmitter}        = require 'events'
 {BufferedWriteStream} = require './buffered'
 
-# This is a Writable Stream.
-#
-# This is an EventEmitter with the following events:
+# A **ClientRequest** is returned when `Client.request()` is called.
+#
+# It is a Writable Stream and responds to the conventional
+# `write` and `end` methods.
+#
+# Its also an EventEmitter with the following events:
 #
 #   Event 'response'
 #   function (response) { }

      serverResponse.writeHead clientResponse.statusCode, clientResponse.headers
      sys.pump clientResponse, serverResponse

exports.createConnection = (port, host) ->
  client = new Client
  client.port = port

    for key, value of metaVariables
      @env[key] = value

  # Write chunk to client
  write: (chunk) ->
    # Netstring encode the chunk and write it to the socket
    @bufferedSocket.write ns.nsWrite(chunk.toString())

  # Closes writting socket.
  end: ->
    @bufferedSocket.end()

# A **ClientResponse** is emitted from the client request's
# `response` event.
#
# It is a Readable Stream and emits the conventional events:
#
#   Event: `data`
#   function (chunk) { }
