SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
Connection * CreateServerConnection()
{
// Declarations
char buffer[1024];
std::string cfgAddress;
unsigned long address;
std::string cfgPort;
unsigned short port;
Connection * result;
// Get address and check that its OK (throw an exception if its not)
cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
// Convert adress to bytes and check that its OK (throw an exception if its not)
address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
// Get port and check that its OK (throw an exception if its not)
cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
// Convert port too bytes
port = htons(atoi(cfgPort.data()));
// Creation connection and check that its OK (throw an exception if its not)
result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
// Return the connection
return result;
}
Connection * CreateServerConnection()
{
// Declarations
char buffer[1024];
std::string cfgAddress;
unsigned long address;
std::string cfgPort;
unsigned short port;
Connection * result;
...
}
Connection * CreateServerConnection()
{
...
// Get address and check that its OK (throw an exception if its not)
cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
}
Connection * CreateServerConnection()
{
...
// Convert adress to bytes and check that its OK (throw an exception if its not)
address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
}
Connection * CreateServerConnection()
{
...
// Get port and check that its OK (throw an exception if its not)
cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
}
Connection * CreateServerConnection()
{
...
// Convert port too bytes
port = htons(atoi(cfgPort.data()));
...
}
Connection * CreateServerConnection()
{
...
// Creation connection and check that its OK (throw an exception if its not)
result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
}
Connection * CreateServerConnection()
{
...
// Return the connection
return result;
}
Connection * CreateServerConnection()
{
// Declarations
...
// Get address and check that its OK (throw an exception if its not)
...
// Convert adress to bytes and check that its OK (throw an exception if its not)
...
// Get port and check that its OK (throw an exception if its not)
...
// Convert port too bytes
...
// Creation connection and check that its OK (throw an exception if its not)
...
// Return the connection
...
}
Connection * CreateServerConnection()
{
// Declarations
...
// Get address and check that it's OK (throw an exception if it's not)
...
// Convert address to bytes and check that it's OK (throw an exception if it's not)
...
// Get port and check that it's OK (throw an exception if it's not)
...
// Convert port to bytes
...
// Creation connection and check that it's OK (throw an exception if it's not)
...
// Return the connection
...
}
Connection * CreateServerConnection()
{
...
...
...
...
...
...
...
}
Connection * CreateServerConnection()
{
char buffer[1024];
std::string cfgAddress;
unsigned long address;
std::string cfgPort;
unsigned short port;
Connection * result;
cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
port = htons(atoi(cfgPort.data()));
result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
Connection * CreateServerConnection()
{
char buffer[1024];
std::string cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
unsigned long address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
std::string cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
unsigned short port = htons(atoi(cfgPort.data()));
Connection * result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(atoi(cfgPort.data()));
Connection * result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
Connection * CreateServerConnection()
{
...
Connection * result = new Connection(address, port);
if(!result || !result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
Connection * CreateServerConnection()
{
...
Connection * result = new Connection(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
std::auto_ptr<Connection> CreateServerConnection()
{
...
std::auto_ptr<Connection> result(new Connection(address, port));
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
std::unique_ptr<Connection> CreateServerConnection()
{
...
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result;
}
Connection * CreateServerConnection()
{
...
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(atoi(cfgPort.data()));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.data());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(atoi(cfgPort.data()));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(atoi(cfgPort.c_str()));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
sprintf(buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
sprintf(buffer, "Invalid address: %s", cfgAddress.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
sprintf(buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
snprintf(buffer, sizeof buffer, "Invalid address: %s", cfgAddress.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "port");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
snprintf(buffer, sizeof buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
return result.release();
}
Connection * CreateServerConnection()
{
char buffer[1024];
...
if(cfgAddress.empty())
{
snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "address");
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
if(address == -1)
{
snprintf(buffer, sizeof buffer, "Invalid address: %s", cfgAddress.c_str());
Log::Instance().Write(buffer);
throw ConnectionException(buffer);
}
...
}
Connection * CreateServerConnection()
{
...
if(cfgAddress.empty())
{
std::stringstream buffer;
buffer << "Configuration value missing: " << "address";
Log::Instance().Write(buffer.str());
throw ConnectionException(buffer.str());
}
...
if(address == -1)
{
std::stringstream buffer;
buffer << "Invalid address: " << cfgAddress;
Log::Instance().Write(buffer.str());
throw ConnectionException(buffer.str());
}
...
}
Connection * CreateServerConnection()
{
...
if(cfgAddress.empty())
{
static const char * logMessage = "Configuration value missing: address";
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
...
if(address == -1)
{
auto logMessage = "Invalid address: " + cfgAddress;
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
...
}
Connection * CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
static const char * logMessage = "Configuration value missing: address";
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
auto logMessage = "Invalid address: " + cfgAddress;
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
static const char * logMessage = "Configuration value missing: port");
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
auto logMessage = "Failed to connect: " + cfgAddress + ":" + cfgPort;
Log::Instance().Write(logMessage);
throw ConnectionException(logMessage);
}
return result.release();
}
Connection * CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
{
FailedToConnect("Configuration value missing: address");
}
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
{
FailedToConnect("Invalid address: " + cfgAddress);
}
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
{
FailedToConnect("Configuration value missing: port");
}
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
{
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
}
return result.release();
}
Connection * CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result.release();
}
std::unique_ptr<Connection> CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result;
}
std::unique_ptr<Connection> CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().GetValue("address");
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
auto cfgPort = ConfigurationManager::Instance().GetValue("port");
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result;
}
std::unique_ptr<Connection> CreateServerConnection()
{
auto cfgAddress = ConfigurationManager::Instance().ValueOf("address");
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
auto cfgPort = ConfigurationManager::Instance().ValueOf("port");
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result;
}
std::unique_ptr<Connection> CreateServerConnection()
{
auto cfgAddress = Configuration::Instance().ValueOf("address");
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
auto cfgPort = Configuration::Instance().ValueOf("port");
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result;
}
std::unique_ptr<Connection> CreateServerConnection(
const std::string & cfgAddress, const std::string & cfgPort)
{
if(cfgAddress.empty())
FailedToConnect("Configuration value missing: address");
auto address = inet_addr(cfgAddress.c_str());
if(address == -1)
FailedToConnect("Invalid address: " + cfgAddress);
if(cfgPort.empty())
FailedToConnect("Configuration value missing: port");
auto port = htons(stoi(cfgPort));
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort);
return result;
}
std::unique_ptr<Connection> CreateServerConnection(
in_addr_t address, in_port_t port)
{
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect(address, port);
return result;
}
std::unique_ptr<Connection> ConnectToServer(in_addr_t address, in_port_t port)
{
auto result = std::make_unique<Connection>(address, port);
if(!result->IsOK())
FailedToConnect(address, port);
return result;
}
std::unique_ptr<Connection> ConnectToServer(in_addr_t address, in_port_t port)
{
return std::make_unique<Connection>(address, port);
}
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Programming Tricks
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Programming Tricks

Contenu connexe

Tendances

Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using c
snsanth
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
DOSONKA Group
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
Prabhu D
 

Tendances (20)

Railwaynew
RailwaynewRailwaynew
Railwaynew
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using c
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
C++ L07-Struct
C++ L07-StructC++ L07-Struct
C++ L07-Struct
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
 
C++ L04-Array+String
C++ L04-Array+StringC++ L04-Array+String
C++ L04-Array+String
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
 
C++ L02-Conversion+enum+Operators
C++ L02-Conversion+enum+OperatorsC++ L02-Conversion+enum+Operators
C++ L02-Conversion+enum+Operators
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
 
C tech questions
C tech questionsC tech questions
C tech questions
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
C++ L11-Polymorphism
C++ L11-PolymorphismC++ L11-Polymorphism
C++ L11-Polymorphism
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 

En vedette

Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
cobyst
 
wordpress training | wordpress certification | wordpress training course | wo...
wordpress training | wordpress certification | wordpress training course | wo...wordpress training | wordpress certification | wordpress training course | wo...
wordpress training | wordpress certification | wordpress training course | wo...
Nancy Thomas
 

En vedette (19)

SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID Deconstruction
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our Ways
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Declarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeDeclarative Thinking, Declarative Practice
Declarative Thinking, Declarative Practice
 
Serializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara HacopianSerializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara Hacopian
 
Scub Foundation, usine logicielle Java libre
Scub Foundation, usine logicielle Java libreScub Foundation, usine logicielle Java libre
Scub Foundation, usine logicielle Java libre
 
Clean architectures
Clean architecturesClean architectures
Clean architectures
 
8 Signs that you are born entrepreneur
8 Signs that you are born entrepreneur8 Signs that you are born entrepreneur
8 Signs that you are born entrepreneur
 
Tailoring classes embroidery fashion designing institute chennai tamil nadu
Tailoring classes embroidery fashion designing institute chennai tamil naduTailoring classes embroidery fashion designing institute chennai tamil nadu
Tailoring classes embroidery fashion designing institute chennai tamil nadu
 
Prototype and Product
Prototype and Product Prototype and Product
Prototype and Product
 
La Educación con sentido del humor
La Educación con sentido del humorLa Educación con sentido del humor
La Educación con sentido del humor
 
Investigación
InvestigaciónInvestigación
Investigación
 
El alma de america vista en un calabazo
El alma de america vista en un calabazoEl alma de america vista en un calabazo
El alma de america vista en un calabazo
 
Though The Lens of an iPhone: Cartagena, Colombia
Though The Lens of an iPhone: Cartagena, ColombiaThough The Lens of an iPhone: Cartagena, Colombia
Though The Lens of an iPhone: Cartagena, Colombia
 
8 preguntas que generan debate en antiagregación - Dr. José Ramón González-Ju...
8 preguntas que generan debate en antiagregación - Dr. José Ramón González-Ju...8 preguntas que generan debate en antiagregación - Dr. José Ramón González-Ju...
8 preguntas que generan debate en antiagregación - Dr. José Ramón González-Ju...
 
Ansible
AnsibleAnsible
Ansible
 
La Organización como Sistema
La Organización como SistemaLa Organización como Sistema
La Organización como Sistema
 
wordpress training | wordpress certification | wordpress training course | wo...
wordpress training | wordpress certification | wordpress training course | wo...wordpress training | wordpress certification | wordpress training course | wo...
wordpress training | wordpress certification | wordpress training course | wo...
 
901 install instant wordpress new
901 install instant wordpress new901 install instant wordpress new
901 install instant wordpress new
 

Similaire à Clean Coders Hate What Happens To Your Code When You Use These Enterprise Programming Tricks

Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
MARRY7
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
ood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdfood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdf
aroramobiles1
 

Similaire à Clean Coders Hate What Happens To Your Code When You Use These Enterprise Programming Tricks (20)

Code as Risk
Code as RiskCode as Risk
Code as Risk
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
 
Winform
WinformWinform
Winform
 
Алексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhereАлексей Кутумов, Coroutines everywhere
Алексей Кутумов, Coroutines everywhere
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32Effective C++/WinRT for UWP and Win32
Effective C++/WinRT for UWP and Win32
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
Asynchronous programming with java script and node.js
Asynchronous programming with java script and node.jsAsynchronous programming with java script and node.js
Asynchronous programming with java script and node.js
 
Ss
SsSs
Ss
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 
ood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdfood evening people. Ive been working on this code that sends a bur.pdf
ood evening people. Ive been working on this code that sends a bur.pdf
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Day 1
Day 1Day 1
Day 1
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
Writing Go(od) Tests (FOSDEM 2020)
Writing Go(od) Tests (FOSDEM 2020)Writing Go(od) Tests (FOSDEM 2020)
Writing Go(od) Tests (FOSDEM 2020)
 
Socket Programming Intro.pptx
Socket  Programming Intro.pptxSocket  Programming Intro.pptx
Socket Programming Intro.pptx
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 

Plus de Kevlin Henney

Plus de Kevlin Henney (20)

Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical Excellence
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical Development
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Get Kata
Get KataGet Kata
Get Kata
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went Away
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
 
Agility ≠ Speed
Agility ≠ SpeedAgility ≠ Speed
Agility ≠ Speed
 
Refactoring to Immutability
Refactoring to ImmutabilityRefactoring to Immutability
Refactoring to Immutability
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
Turning Development Outside-In
Turning Development Outside-InTurning Development Outside-In
Turning Development Outside-In
 
Giving Code a Good Name
Giving Code a Good NameGiving Code a Good Name
Giving Code a Good Name
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation Quadrant
 
Software Is Details
Software Is DetailsSoftware Is Details
Software Is Details
 
Game of Sprints
Game of SprintsGame of Sprints
Game of Sprints
 
Good Code
Good CodeGood Code
Good Code
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many Programmers
 

Dernier

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Dernier (20)

WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 

Clean Coders Hate What Happens To Your Code When You Use These Enterprise Programming Tricks

  • 1.
  • 2.
  • 3. Connection * CreateServerConnection() { // Declarations char buffer[1024]; std::string cfgAddress; unsigned long address; std::string cfgPort; unsigned short port; Connection * result; // Get address and check that its OK (throw an exception if its not) cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } // Convert adress to bytes and check that its OK (throw an exception if its not) address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } // Get port and check that its OK (throw an exception if its not) cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } // Convert port too bytes port = htons(atoi(cfgPort.data())); // Creation connection and check that its OK (throw an exception if its not) result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } // Return the connection return result; }
  • 4. Connection * CreateServerConnection() { // Declarations char buffer[1024]; std::string cfgAddress; unsigned long address; std::string cfgPort; unsigned short port; Connection * result; ... }
  • 5. Connection * CreateServerConnection() { ... // Get address and check that its OK (throw an exception if its not) cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... }
  • 6. Connection * CreateServerConnection() { ... // Convert adress to bytes and check that its OK (throw an exception if its not) address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... }
  • 7. Connection * CreateServerConnection() { ... // Get port and check that its OK (throw an exception if its not) cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... }
  • 8. Connection * CreateServerConnection() { ... // Convert port too bytes port = htons(atoi(cfgPort.data())); ... }
  • 9. Connection * CreateServerConnection() { ... // Creation connection and check that its OK (throw an exception if its not) result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... }
  • 10. Connection * CreateServerConnection() { ... // Return the connection return result; }
  • 11. Connection * CreateServerConnection() { // Declarations ... // Get address and check that its OK (throw an exception if its not) ... // Convert adress to bytes and check that its OK (throw an exception if its not) ... // Get port and check that its OK (throw an exception if its not) ... // Convert port too bytes ... // Creation connection and check that its OK (throw an exception if its not) ... // Return the connection ... }
  • 12. Connection * CreateServerConnection() { // Declarations ... // Get address and check that it's OK (throw an exception if it's not) ... // Convert address to bytes and check that it's OK (throw an exception if it's not) ... // Get port and check that it's OK (throw an exception if it's not) ... // Convert port to bytes ... // Creation connection and check that it's OK (throw an exception if it's not) ... // Return the connection ... }
  • 14. Connection * CreateServerConnection() { char buffer[1024]; std::string cfgAddress; unsigned long address; std::string cfgPort; unsigned short port; Connection * result; cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } port = htons(atoi(cfgPort.data())); result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 15. Connection * CreateServerConnection() { char buffer[1024]; std::string cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } unsigned long address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } std::string cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } unsigned short port = htons(atoi(cfgPort.data())); Connection * result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 16. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(atoi(cfgPort.data())); Connection * result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 17. Connection * CreateServerConnection() { ... Connection * result = new Connection(address, port); if(!result || !result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 18. Connection * CreateServerConnection() { ... Connection * result = new Connection(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 19. std::auto_ptr<Connection> CreateServerConnection() { ... std::auto_ptr<Connection> result(new Connection(address, port)); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 20. std::unique_ptr<Connection> CreateServerConnection() { ... auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result; }
  • 21. Connection * CreateServerConnection() { ... auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 22. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(atoi(cfgPort.data())); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 23. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.data()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(atoi(cfgPort.data())); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.data(), cfgPort.data()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 24. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(atoi(cfgPort.c_str())); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 25. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 26. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { sprintf(buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { sprintf(buffer, "Invalid address: %s", cfgAddress.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { sprintf(buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { sprintf(buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 27. Connection * CreateServerConnection() { char buffer[1024]; auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { snprintf(buffer, sizeof buffer, "Invalid address: %s", cfgAddress.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "port"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { snprintf(buffer, sizeof buffer, "Failed to connect: %s:%s", cfgAddress.c_str(), cfgPort.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } return result.release(); }
  • 28. Connection * CreateServerConnection() { char buffer[1024]; ... if(cfgAddress.empty()) { snprintf(buffer, sizeof buffer, "Configuration value missing: %s", "address"); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... if(address == -1) { snprintf(buffer, sizeof buffer, "Invalid address: %s", cfgAddress.c_str()); Log::Instance().Write(buffer); throw ConnectionException(buffer); } ... }
  • 29. Connection * CreateServerConnection() { ... if(cfgAddress.empty()) { std::stringstream buffer; buffer << "Configuration value missing: " << "address"; Log::Instance().Write(buffer.str()); throw ConnectionException(buffer.str()); } ... if(address == -1) { std::stringstream buffer; buffer << "Invalid address: " << cfgAddress; Log::Instance().Write(buffer.str()); throw ConnectionException(buffer.str()); } ... }
  • 30. Connection * CreateServerConnection() { ... if(cfgAddress.empty()) { static const char * logMessage = "Configuration value missing: address"; Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } ... if(address == -1) { auto logMessage = "Invalid address: " + cfgAddress; Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } ... }
  • 31. Connection * CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { static const char * logMessage = "Configuration value missing: address"; Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { auto logMessage = "Invalid address: " + cfgAddress; Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { static const char * logMessage = "Configuration value missing: port"); Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { auto logMessage = "Failed to connect: " + cfgAddress + ":" + cfgPort; Log::Instance().Write(logMessage); throw ConnectionException(logMessage); } return result.release(); }
  • 32. Connection * CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) { FailedToConnect("Configuration value missing: address"); } auto address = inet_addr(cfgAddress.c_str()); if(address == -1) { FailedToConnect("Invalid address: " + cfgAddress); } auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) { FailedToConnect("Configuration value missing: port"); } auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) { FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); } return result.release(); }
  • 33. Connection * CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result.release(); }
  • 34. std::unique_ptr<Connection> CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result; }
  • 35. std::unique_ptr<Connection> CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().GetValue("address"); if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); auto cfgPort = ConfigurationManager::Instance().GetValue("port"); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result; }
  • 36. std::unique_ptr<Connection> CreateServerConnection() { auto cfgAddress = ConfigurationManager::Instance().ValueOf("address"); if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); auto cfgPort = ConfigurationManager::Instance().ValueOf("port"); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result; }
  • 37. std::unique_ptr<Connection> CreateServerConnection() { auto cfgAddress = Configuration::Instance().ValueOf("address"); if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); auto cfgPort = Configuration::Instance().ValueOf("port"); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result; }
  • 38. std::unique_ptr<Connection> CreateServerConnection( const std::string & cfgAddress, const std::string & cfgPort) { if(cfgAddress.empty()) FailedToConnect("Configuration value missing: address"); auto address = inet_addr(cfgAddress.c_str()); if(address == -1) FailedToConnect("Invalid address: " + cfgAddress); if(cfgPort.empty()) FailedToConnect("Configuration value missing: port"); auto port = htons(stoi(cfgPort)); auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect("Failed to connect: " + cfgAddress + ":" + cfgPort); return result; }
  • 39. std::unique_ptr<Connection> CreateServerConnection( in_addr_t address, in_port_t port) { auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect(address, port); return result; }
  • 40. std::unique_ptr<Connection> ConnectToServer(in_addr_t address, in_port_t port) { auto result = std::make_unique<Connection>(address, port); if(!result->IsOK()) FailedToConnect(address, port); return result; }
  • 41. std::unique_ptr<Connection> ConnectToServer(in_addr_t address, in_port_t port) { return std::make_unique<Connection>(address, port); }