From 5e8e50e53bced13906859ae9a1b23315c907f353 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Jun 2013 13:11:31 -0700 Subject: [PATCH] the EC2 domain server should send to the Agent's local socket --- domain-server/src/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 67c1123205..028f4cb508 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -65,8 +65,8 @@ int main(int argc, const char * argv[]) // with the EC2 IP. Otherwise, we will replace the IP like we used to // this allows developers to run a local domain without recompiling the // domain server - bool useLocal = cmdOptionExists(argc, argv, "--local"); - if (useLocal) { + bool isLocalMode = cmdOptionExists(argc, argv, "--local"); + if (isLocalMode) { printf("NOTE: Running in Local Mode!\n"); } else { printf("--------------------------------------------------\n"); @@ -109,7 +109,7 @@ int main(int argc, const char * argv[]) if (agentPublicAddress.sin_addr.s_addr == serverLocalAddress) { // If we're not running "local" then we do replace the IP // with the EC2 IP. Otherwise, we use our normal public IP - if (!useLocal) { + if (!isLocalMode) { agentPublicAddress.sin_addr.s_addr = 895283510; // local IP in this format... } } @@ -177,10 +177,12 @@ int main(int argc, const char * argv[]) // add the agent ID to the end of the pointer currentBufferPos += packAgentId(currentBufferPos, newAgent->getAgentID()); + sockaddr* destinationSocket = (sockaddr*) (isLocalMode ? &agentPublicAddress : &agentLocalAddress); + // send the constructed list back to this agent - agentList->getAgentSocket()->send((sockaddr*) &agentPublicAddress, - broadcastPacket, - (currentBufferPos - startPointer) + 1); + agentList->getAgentSocket()->send(destinationSocket, + broadcastPacket, + (currentBufferPos - startPointer) + 1); } }