IRSOL
C++ code implementing socket server for interacting with Baumer camera.
server.cpp File Reference

Example camera server for client-server interaction with image commands. More...

#include "irsol/irsol.hpp"
#include <string>
#include <thread>

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Example camera server for client-server interaction with image commands.

This executable launches a TCP camera server using the IRSOL framework. It listens for incoming client connections and processes image acquisition commands, such as gi (get image) and gis (get image stream), distributing frames to clients as requested.

Usage: ./06-client-server-interaction-image-commands-server

The server runs until the user presses 'q' in the terminal, at which point it shuts down gracefully. All logging is written to logs/camera-server.log.

Definition in file server.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 23 of file server.cpp.

24{
25
26 irsol::initLogging("logs/camera-server.log");
28
29 IRSOL_LOG_INFO("Sample TCP camera server");
30
31 in_port_t port = 15099; // port used by existing clients
32
33 irsol::server::App app(port);
34 if(!app.start()) {
35 IRSOL_LOG_FATAL("Failed to start server.");
36 return 1;
37 }
38
39 IRSOL_LOG_INFO("Server running. Press 'q' to quit.");
40 while(true) {
41 char c = std::cin.get();
42 if(c == 'q') {
43 IRSOL_LOG_INFO("Stopping server...");
44 app.stop();
45 break;
46 } else {
47 IRSOL_LOG_WARN("Invalid input '{}'. Press 'q' to quit.", c);
48 }
49 }
50
51 return 0;
52}
Main server application that manages client connections and camera streaming.
Definition app.hpp:46
void initAssertHandler()
Initializes the assertion handler system.
Definition assert.cpp:14
#define IRSOL_LOG_FATAL(...)
Logs a fatal (critical) message using the default logger.
Definition logging.hpp:95
#define IRSOL_LOG_INFO(...)
Logs an info-level message using the default logger.
Definition logging.hpp:92
#define IRSOL_LOG_WARN(...)
Logs a warning-level message using the default logger.
Definition logging.hpp:93
void initLogging(const char *fileSinkFilename="logs/irsol.log", std::optional< spdlog::level::level_enum > minLogLevel=std::nullopt)
Initializes the irsol logging system.
Definition logging.cpp:108