SendRecvResponse sendAllRequestsByTCP(
			Map<Integer, TaskAssignment> tasksMap, byte taskTypeCode) {
		SendRecvResponse output = new SendRecvResponse();
		ExecutorService executor = Executors.newFixedThreadPool(Runtime
				.getRuntime().availableProcessors());
		AtomicBoolean exception = new AtomicBoolean(false);
		AtomicBoolean fault = new AtomicBoolean(false);
		// Send map task requests.
		/*
		 * for (int taskNo : tasksMap.keySet()) { TaskAssignment assignment =
		 * tasksMap.get(taskNo); PubSubMessage request =
		 * assignment.getTaskRequest(); // execute
		 * HandleTaskRequestSendingThread thread = new
		 * HandleTaskRequestSendingThread( assignment.getAssignedDaemon(),
		 * request, taskTypeCode, exception, fault); executor.execute(thread); }
		 */
		Map<Integer, MapTaskGroupRequest> mapDistribution = new HashMap<Integer, MapTaskGroupRequest>();
		for (int taskNo : tasksMap.keySet()) {
			TaskAssignment assignment = tasksMap.get(taskNo);
			MapTaskRequest request = (MapTaskRequest) assignment
					.getTaskRequest();
			MapTaskGroupRequest requests = mapDistribution.get(assignment
					.getAssignedDaemon());
			if (requests == null) {
				requests = new MapTaskGroupRequest();
				mapDistribution.put(assignment.getAssignedDaemon(), requests);
			}
			requests.getMapRequests().add(request);
		}
		for (int daemonID : mapDistribution.keySet()) {
			// execute
			HandleTaskRequestSendingThread thread = new HandleTaskRequestSendingThread(
					daemonID, mapDistribution.get(daemonID), taskTypeCode,
					exception, fault);
			executor.execute(thread);
		}
		executor.shutdown(); // Disable new tasks from being submitted
		try {
			if (!executor.awaitTermination(600, TimeUnit.SECONDS)) {
				System.out
						.println("It still sends request after 10 minutes...");
				executor.shutdownNow(); // Cancel currently executing
										// tasks
				// Wait a while for tasks to respond to being cancelled
				if (!executor.awaitTermination(300, TimeUnit.SECONDS)) {
					System.err
							.println("Sending cmd does not terminate in 5 minutes.");
				}
			}
		} catch (InterruptedException e) {
			// (Re-)Cancel if current thread also interrupted
			executor.shutdownNow();
			// Preserve interrupt status
			Thread.currentThread().interrupt();
		}
		// if exception throws
		if (exception.get()) {
			output.setStatus(SendRecvStatus.LOCAL_EXCEPTION);
			return output;
		}
		// if fault, throws
		if (fault.get()) {
			output.setStatus(SendRecvStatus.REMOTE_FALIURE);
			return output;
		}
		// if all sent, we believe it is successful
		output.setStatus(SendRecvStatus.SUCCESS);
		return output;
	}