Browse Source

Added some comments

Paul-Louis Ageneau 3 years ago
parent
commit
a2da37cbc8
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/impl/tcptransport.cpp

+ 4 - 0
src/impl/tcptransport.cpp

@@ -130,6 +130,7 @@ void TcpTransport::connect() {
 	PLOG_DEBUG << "Connecting to " << mHostname << ":" << mService;
 	PLOG_DEBUG << "Connecting to " << mHostname << ":" << mService;
 	changeState(State::Connecting);
 	changeState(State::Connecting);
 
 
+	// Resolve hostname
 	struct addrinfo hints = {};
 	struct addrinfo hints = {};
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
 	hints.ai_socktype = SOCK_STREAM;
@@ -140,6 +141,7 @@ void TcpTransport::connect() {
 	if (getaddrinfo(mHostname.c_str(), mService.c_str(), &hints, &result))
 	if (getaddrinfo(mHostname.c_str(), mService.c_str(), &hints, &result))
 		throw std::runtime_error("Resolution failed for \"" + mHostname + ":" + mService + "\"");
 		throw std::runtime_error("Resolution failed for \"" + mHostname + ":" + mService + "\"");
 
 
+	// Chain connection attempt to each address
 	auto attempt = [this, result](struct addrinfo *ai, auto recurse) {
 	auto attempt = [this, result](struct addrinfo *ai, auto recurse) {
 		if (!ai) {
 		if (!ai) {
 			PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
 			PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
@@ -156,6 +158,7 @@ void TcpTransport::connect() {
 			recurse(ai->ai_next, recurse);
 			recurse(ai->ai_next, recurse);
 		}
 		}
 
 
+		// Poll out event callback
 		auto callback = [this, result, ai, recurse](PollService::Event event) mutable {
 		auto callback = [this, result, ai, recurse](PollService::Event event) mutable {
 			try {
 			try {
 				if (event == PollService::Event::Error)
 				if (event == PollService::Event::Error)
@@ -178,6 +181,7 @@ void TcpTransport::connect() {
 					throw std::runtime_error(msg.str());
 					throw std::runtime_error(msg.str());
 				}
 				}
 
 
+				// Success
 				PLOG_INFO << "TCP connected";
 				PLOG_INFO << "TCP connected";
 				freeaddrinfo(result);
 				freeaddrinfo(result);
 				changeState(State::Connected);
 				changeState(State::Connected);