 
       unless job.aborted
         job.abort()
-        job.emit "error", new Error("Job failed")
+        job.emit "error", new Error "Job failed"
 
   receive_WORK_DATA: (handle, payload) ->
     if @currentJobs[handle] and not @currentJobs[handle].aborted

      body[curpos++] = 0x00  if i < args.length - 1
      i++
    if @debug
      console.log "Sending: " + commandName + " with " + args.length + " params"
      console.log " - ", body
      args.forEach (arg, i) ->
        console.log "  - ARG:" + i + " ", arg.toString()
    @socket.write body, @processCommandQueue.bind(this)

  receive: (chunk) ->
    data = new Buffer((chunk and chunk.length or 0) + (@remainder and @remainder.length or 0))
    commandId = undefined
    commandName = undefined
    bodyLength = 0
    args = []
    argTypes = undefined
    curarg = undefined
    i = undefined
    len = undefined
    argpos = undefined
    curpos = undefined
    return  unless data.length
    if @remainder
      @remainder.copy data, 0, 0
      chunk.copy data, @remainder.length, 0  if chunk
    else
      data = chunk
    if data.length < 12
      @remainder = data
      return
    return @errorHandler(new Error("Out of sync with server"))  unless data.readUInt32BE(0) is 0x00524553
    bodyLength = data.readUInt32BE(8)
    if data.length < 12 + bodyLength
      @remainder = data
      return
    if data.length > 12 + bodyLength
      @remainder = data.slice(12 + bodyLength)
      data = data.slice(0, 12 + bodyLength)
    else
      @remainder = false
    commandId = data.readUInt32BE(4)
    commandName = (Gearman.packetTypesReversed[commandId] or "")
    return  unless commandName
    if bodyLength and (argTypes = Gearman.paramCount[commandName])
      curpos = 12
      argpos = 12
      i = 0

    SUBMIT_JOB_SCHED: 35
    SUBMIT_JOB_EPOCH: 36

  @packetTypesReversed:
    1: "CAN_DO"
    2: "CANT_DO"
    3: "RESET_ABILITIES"
