IPC between FastCGI C++ / Nginx and C++ Application - c++

I'm trying to create a Gateway which offers a RESTful interface to send/receive messages to Devices which communicate over Bluetooth Low Energy (BLE). Basically it translates GATT to HTTP and vice versa.
The basic architecture looks as follows:
A BLE Dongle is connected to a Linux computer (f.e. Raspberry Pi) a C-Program opens a serial connection to the BLE Dongle to send/receive/process messages. It receives requests from a C++ Application over IPC using a TCP/IP Socket and also uses this socket to forward replies from BLE Devices (f.e. Sensors) to the C++ Application (which acts as a multithreaded server for each connected BLE Dongle).
The C++ Application saves this information (f.e. discovered devices, connected devices and their data) and also implements an interface to control basic Bluetooth Low Energy functions like Discovery,Connect.. etc.
A client can send HTTP Requests (GET/POST) to a Nginx Webserver which uses FastCGI. I would like to parse the requests in this FastCGI Application and then communicate with the C++ Application to execute the commands
f.e. Client opens an URI xyz/discover sending a GET Request. The FastCGI Application parses this requests and calls the Discover function of the C++ Application to start a Bluetooth Low Energy discovery.
My Question is how to best communicate between the C++ Application and the FastCGI C++ Application.
My Ideas:
The C++ App forks a new child which does exec fcgi-spawn (path to my fcgi app as an argument). Then create two pipes for full-duplex communication between parent and child
Using named Pipes between both processes
Is it a good idea to just integrate the FastCGI functionality in my C++ Application? The C++ App runs several Threads: one to accept new TCP connections in case a new Dongle is connected. It starts a Thread for each new Dongle. Could I just create another thread which is responsible for parsing FastCGI Requests?
Since I never really worked with FastCGI and nginx I'm just learning as I go. So I would be grateful for some input. Thanks!

Related

C++ terminal server for existing terminal client protocol

I want to communicate with a C++ simulated UART which is communicating with a (simulated) guest Linux system terminal.
What I have is a callback called when receiving character outputs from the UART, and a method I can call to send characters to this same UART.
I'd like to be able to connect to this UART with my host terminal, implementing a server socket communicating using an existing protocol.
What protocol should I use to keep a high compatibility? I'm thinking about telnet. Are there existing frameworks in C++ or C to implement that quick and easy?

How to get Socket connect through proxifier

I made a simple program in c++ for connecting to a site and loading a page HTML code or send data using GET/POST requests.
But now I want the program to connect and send/receive data through proxy.
You probably know software like NextVpn and proxifier. when they are running any application which tries to communicate through internet will have to go through these apps.
The problem is that my program connects and communicates directly and my proxy software doesn't interfere.
Communication is done by the socket programming routins (SOCKET class) like this
SOCKET sck=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
connect(sck,(SOCKADDR*)(&SockAddr),sizeof(SockAddr));
send(sck,myRequest,strlen(myRequest),0);
Any solution?
EDIT: The problem was from NextVPN not the Proxifier itself. It seems that NextVPN lacks functionality in hooking into some programs. First NextVPN finds the program which is trying to connect to a remote address then redirects it to its portable version of proxifier with something named "compose.ns" . Unfortunately it was unable or couldn't detect my app connecting to internet. Instead I used Proxifier itself and it successfully detected my app as it was showing in its connection list.

Connecting non-IOCP client with IOCP Server

I am designing a client-server application.
My server will be in C++ and using IOCP for TCP/IP communication.
Decision for technology for client development not decided yet. So I have few questions regarding IOCP compatibility with client to be developed in future (I need to freeze design for Server):
Can I use general socket programming of java(client will be developed in java more likely) to communicate IOCP based Server?
How IOCP responds for abrupt and graceful termination of client connection (what notification I'll get on server)?
Thanks
Nipun
You are talking about socket programming here, and the middle layer is TCP/IP and so the network programming library (e.g. IOCP) is irrelevant. You can use whatever language or library on the client side.
For first question,yes you can use any language as long as you use TCP/IP protocol.
For second question,my solution is,create an stop event for iocp,and every once a while,send a little package to client,if client does not reply this package,set the stop event up,and release the connection for the client

Socket communication between c++ Client and node.js Server

I want to make my c++ app (running on Linux system) to connect and send data to node.server via socket.
I tried to implement small sample app by using socket.io library (https://github.com/uning/socket.io-client-cpp), but doesnt helping me to achieve my goal.
Any guidance on this or alternative to do something like this.

C++ & Boost: I'm trying to find an example TCP program with a server that accepts connections from multiple clients

A chat program would be a good enough example.
Just need a server that can accept multiple connections from the clients, and the server needs to be able to send messages to individual clients.
I plan to turn this into a distributed computing program to work with multiple Neural Networks.
Asio is the Boost library that handles networking. There's a chat server example listed here.
I cannot give you an example progam. But to write a server things that you have to do:
1. server will listen at a port for connection
2. thread pool which will accept the connection and serve request
3. write the server code in thread safe manner
You have to use socket programming A good link for that http://beej.us/guide/bgnet/
you can use win32 api in windows and posix for linux