     return callback err, null
 
   response =
+    body: ''
     transaction: {}
 
   logger.info('Rerun Transaction #' + transaction._id + ' - HTTP Request is being sent...')
   req = http.request options, (res) ->
-    response.body = ''
 
     res.on "data", (chunk) ->
       # response data

client = monq(config.mongo.url, safe: true)
http = require 'http'
TransactionModel = require("../model/transactions").Transaction


#####################################################################################################

# Function for updating the task object with response details #
###############################################################

rerunTcpRequestSend = (channel, transaction, callback) ->

  response =
    body: ''
    transaction: {}

  client = new net.Socket()

  client.connect channel.tcpPort, channel.tcpHost, ->
    console.log "Connected"
    client.end transaction.request.body
    return

  client.on "data", (data) ->
    console.log "Received: " + data
    response.body += data
    client.destroy() # kill client after server's response

  client.on "end" , (err) ->
    console.log "Connection closed"
    response.status = 200
    response.transaction.status = "Completed"
    response.message = ''
    response.headers = {}
    response.timestamp = new Date

    logger.info('Rerun Transaction #' + transaction._id + ' - TCP Response has been captured')
    callback err, response
    return

#########################################################
# Export these functions when in the "test" environment #
