 # 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 #

    return callback err, null

  response =
    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

TaskModel = require('../model/tasks').Task
Channel = require('../model/channels').Channel
Q = require("q")
logger = require("winston")
monq = require("monq")
