![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Demonstrates a sample client-server interaction using sockets. More...
#include "irsol/irsol.hpp"
#include "sockpp/tcp_acceptor.h"
#include "sockpp/tcp_connector.h"
#include <chrono>
#include <random>
#include <string>
#include <thread>
#include <vector>
Go to the source code of this file.
Classes | |
struct | Params |
Command-line parameters for the program. More... | |
Macros | |
#define | PROGRAM_NAME "client-server-interaction-demo" |
Functions | |
const std::string | getProgramName () |
std::thread | runServerThread (irsol::server::App &app) |
Demonstrates handler creation, registration, and dispatch. | |
void | clientThreadBody (std::string clientName, irsol::types::port_t port, std::vector< std::string > commands) |
The function executed by each client thread. | |
std::thread | runClientThread (const std::string &clientName, irsol::types::port_t port, const std::vector< std::string > commands) |
TCP client that connects to the server and sends commands at random intervals. | |
Params | getParams (int argc, char **argv) |
Parses command-line arguments using args library. | |
void | runDemo (uint32_t numClients) |
int | main (int argc, char **argv) |
Main entry point for the handler demo application. | |
Demonstrates a sample client-server interaction using sockets.
it=number
) will cause the server to broadcast a confirmation message to all connected clients. As a result, each client may receive more messages than it sends.Build system integration is expected to define PROGRAM_NAME
for logging.
Definition in file main.cpp.
#define PROGRAM_NAME "client-server-interaction-demo" |
void clientThreadBody | ( | std::string | clientName, |
irsol::types::port_t | port, | ||
std::vector< std::string > | commands | ||
) |
The function executed by each client thread.
Definition at line 47 of file main.cpp.
Params getParams | ( | int | argc, |
char ** | argv | ||
) |
Parses command-line arguments using args
library.
Supported arguments:
--clients
, -c
: Set number of clients to run concurrently--help
, -h
: Show help message and exitargc | Argument count |
argv | Argument vector |
Params
struct Definition at line 112 of file main.cpp.
const std::string getProgramName | ( | ) |
int main | ( | int | argc, |
char ** | argv | ||
) |
Main entry point for the handler demo application.
Definition at line 180 of file main.cpp.
std::thread runClientThread | ( | const std::string & | clientName, |
irsol::types::port_t | port, | ||
const std::vector< std::string > | commands | ||
) |
TCP client that connects to the server and sends commands at random intervals.
Definition at line 87 of file main.cpp.
void runDemo | ( | uint32_t | numClients | ) |
Definition at line 138 of file main.cpp.
std::thread runServerThread | ( | irsol::server::App & | app | ) |