Socket Connection on the client side.
As always, full code description and documentation on github https://github.com/nucleoType98/Unix_Client_Socket.git
Simple Connection
More Configurations
As always, full code description and documentation on github https://github.com/nucleoType98/Unix_Client_Socket.git
Simple Connection
Code
#include "client.cpp"
using namespace ClientSocket;
// command line arguments are used to sent data directly from the command line
int main(int argc, char **argv) {
Socket *SocketConnection = new Socket();
SocketConnection->set_end_point_ip("127.0.0.1");
SocketConnection->set_end_point_port(3300);
// connect with persistence, meaning if the connection fails, it will try to connect again using the value supplied
// by SocketConnection->set_connection_exe_max(10000)
SocketConnection->create_connection(ClientSocket::CONNECTION_MODE::PERSISTENT);
delete SocketConnection;
return 0;
}More Configurations
Code
#include "client.cpp"
using namespace ClientSocket;
// command line arguments are used to sent data directly from the command line
int main(int argc, char **argv) {
Socket *SocketConnection = new Socket();
SocketConnection->set_end_point_ip("127.0.0.1"); // set the end point ip address
SocketConnection->set_end_point_port(3300); // set the end point port number
SocketConnection->set_connection_exe_max(10000); // set maximum number of connection tries before aborting
SocketConnection->set_connection_exe_speed(100000); // set connection execution speed
// connect with persistence, meaning if the connection fails, it will try to connect again using the value supplied by SocketConnection->set_connection_exe_max(10000)
SocketConnection->create_connection(ClientSocket::CONNECTION_MODE::PERSISTENT);
if (SocketConnection->is_connected()) {
SocketConnection->send_message("Something to send to the server");
SocketConnection->send_encrypted_message("Demo Encrypted Payload Data", 10); // send encrypted data, using a key value = 10, decryption must be handled on server side
SocketConnection->send_message_as_cli_arg(argc, argv); // send message supplied by command line args
SocketConnection->commander_mode(); // wait for data exchange from server, uses a detached thread
SocketConnection->disconnect(); // disconnect from server
}
delete SocketConnection;
return 0;
}
