Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C++ Client Side Socket Channel

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
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;
}
(Apr 23, 2024 02:37 PM)nucleo_type09 Wrote:  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
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;
}

Nice share!! Looks good - haven't tested it, but well documented, commented, and structured when looking through
What were the hardest parts?

quick heads up, your client.hpp file is blank, not sure if you know that:
Quote:https://raw.githubusercontent.com/nucleo...client.hpp

(Apr 23, 2024 03:41 PM)Hackers Wrote:  Nice share!! Looks good - haven't tested it, but well documented, commented, and structured when looking through
What were the hardest parts?

quick heads up, your client.hpp file is blank, not sure if you know that:

thanks man, i appreciate that :), really? is it? did not notice at all, damn git commands, they're bugged haha, let me have a look :), it is possible tho, i've been writing that all day long, so maybe something gone wrong haha, thanks for pointing that out , appreciate your help...
(Apr 23, 2024 03:44 PM)nucleo_type09 Wrote:  thanks man, i appreciate that :), really? is it? did not notice at all, let me have a look :), it is possible tho, i've been writing that all day long, so maybe something gone wrong haha, thanks for pointing that out , appreciate your help...

heh yep it is! No problem, figured it was just a fluke
(Apr 23, 2024 03:41 PM)Hackers Wrote:  Nice share!! Looks good - haven't tested it, but well documented, commented, and structured when looking through
What were the hardest parts?

quick heads up, your client.hpp file is blank, not sure if you know that:

not really, there wasn't anything so hard at all , to be honest i find worse doing the documentation haha
(Apr 23, 2024 03:45 PM)nucleo_type09 Wrote:  not really, there wasn't anything so hard at all , to be honest i find worse doing the documentation haha

lol I know what you mean
there are times where I'm spending more time on the github readme.md than the code and I have to ask myself, "should I be doing this???" - for the record my answer is Yes, because it's a record of what it is, and 99.99% of the time I write good comments/docs, I appreciate it later, so I always try to spend the time. Anytime I skip the commenting/documentation process, I regret it later usually.
(Apr 23, 2024 03:45 PM)Hackers Wrote:  heh yep it is! No problem, figured it was just a fluke

thanks man, you were right, i dont know what went wrong, probably git command were bugged somehow haha, the files were ok in my local workspace, i added them to github as well as soon as you told me about it haha, bro without your intervention that files would be missing forever haha, thanks again 😎, BTW, the hardest part on coding was not really on this client side library, but rather on the other one, the server side one, which is 3 times bigger and complex than this one, yeah that one took me 2 days to write


(Apr 23, 2024 03:50 PM)Hackers Wrote:  lol I know what you mean
there are times where I'm spending more time on the github readme.md than the code and I have to ask myself, "should I be doing this???" - for the record my answer is Yes, because it's a record of what it is, and 99.99% of the time I write good comments/docs, I appreciate it later, so I always try to spend the time. Anytime I skip the commenting/documentation process, I regret it later usually.

😵😵 Me too, that's why i spend lot of time documenting it, because i wont sleep at night knowing that the codebase is good, but the documentation sucks haha🤣


(Apr 23, 2024 03:45 PM)Hackers Wrote:  heh yep it is! No problem, figured it was just a fluke

it was indeed haha✌😎, thanks for your intervention on that one, i would never have notice it


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Mr.7Oct 28, 2019 12:45 PM 2 136 Oct 28, 2019 12:45 PM
Last Post: Goodies
[C#] by itsnodeFeb 4, 2018 12:21 AM 17 1,213 Feb 4, 2018 12:21 AM
Last Post: gungunfebrianza
[Python] by iboyhacker_1997Aug 22, 2017 02:02 PM 5 199 Aug 22, 2017 02:02 PM
Last Post: xorn.91