     return true
 
   tcp.on 'data', (data) ->
-    console.error "data: #{data}"
     handleData = () ->
       return unless strBuffer.length > 0
       if firstLine



  handleClose = (variables, data) ->
    console.error "handleClose"
    file = variables.token
    console.error "Closed #{file}" if options.verbose


  # this is difficult to parse because we don't know in advance if we have the full message
  # or due to lack of unique delimiter, so we need to make this function reentrant
  handleCmd = () ->
    unless cmdObj.cmd?
      [cmd, strBuffer] = readLine strBuffer
      return false unless cmd?
      cmdObj.cmd = cmd

    cmdObj.variables = {}

    assignData = () ->
      {size} = cmdObj
      return false unless strBuffer.length >= size
      cmdObj.data = strBuffer[..(size - 1)]
      strBuffer = strBuffer[size..]
      return true

    # in case we exited after we got data size, but not the whole data payload
    if cmdObj.size? and not cmdObj.data?
      return false unless assignData()

    # read in variables
    [line, strBuffer] = readLine strBuffer
    return false unless line?
    while line isnt "\n"
      [name, value] = line.split(": ", 2)
      if name is "data"
        cmdObj.size = parseInt(value)
