Multiple Simultaneous gRPC connections to different servers via different interfaces (eth0, wlan0, ppp0) - c++

We have started using gRPC C++ for our embedded system project (ARM Processor Cortex-A7) as a client. We have successfully created a sample application which communicates with the server using protobuf.
We have a new requirement now. We have to open multiple connections to the different endpoints (or server) via different interfaces (like ethernet, wifi and cellular [using ppp]).
I tried to google but couldn't find any solutions to it. I have tried gRPC forum but hasn't received a proper reply to my question.
I have wondering if gRPC has provision to bind to a particular interface or IP. Linux POSIX socket provides SO_BINDTODEVICE option but I am not sure if gRPC has any application layer method or function to achieve it (can't find it in the documentation).
Or Can we achieve it via some other hack (may be by modifying the routing table?).

Related

What is required to get a BSD-sockets-based program to do LAN networking under Emscripten?

Background: I've got an C++/Qt-based application that communicates with servers on the user's LAN. It uses non-blocking TCP and UDP sockets, and the networking is implemented via calls to the BSD sockets API (i.e. socket()/send()/recv()/select()/etc). It all works well.
The other day, just for fun, I decided to recompile the application using emscripten, so that it could run as a WebAssembly app inside a web browser.
This worked surprisingly well -- within an hour or two, I had my app up and running inside Google Chrome. However, the app's usefulness in this configuration is severely limited by the fact that it isn't able to connect to any servers -- presumably this is because it is running in a restricted/sandboxed environment.
If I wanted to pursue this line of development beyond the clever-hack-demo stage and try to make it useful, I would need to find a way for my program to discover and connect to servers on the user's LAN.
My question is: is that functionality at all possible for a Emscripten/WebAssembly-based app to perform? If so, what steps would I need to take? (i.e. would it require upgrading the LAN's servers to handle WebSocket-based connections? Would it require adding some sort of proxy server to run on the web server that the web page was served from? Is UDP even a thing in a web-app context? Are there other hoops that would also have to be jumped through?)

NodeJS server send data to C++ process

I have a nodeJS server which receives user POST/Streaming requests from a web-UI.
I have a C++ back-end engine process which does some calculations and sends API calls to other 3rd party services. The API call requires certain info provided by the web users.
My question is what is the best solution to pass the request data received on NodeJS and send over to the C++ process?
WebUI -> NodeJS ->???->> C++ engine
Make your C++ application listen on a TCP or Unix socket.
Make your NodeJs application connect to that socket and exchange messages. For messages you can use Google Protocol Buffers, JSON, etc..
If the information what you have is still at JavaScript layer, then you have to implement C/C++ Addons implementation. If you already have some type of native module, then you may follow the same design based on that (very likely existing module could be based on NAN). If you are plan to introduce a brand new native module then it is a good time to consider N-API. You can get more information about it from.
https://nodejs.org/dist/latest-v11.x/docs/api/n-api.html
https://github.com/nodejs/node-addon-api

Application specific network interface in CEF3 based application

I am writing a CEF3 based application. I have a requirement, where I can show available network interface and select any of them. Once I have selected the network interface all the traffic should route through that selected network interface. For example if I am having one Ethernet one wifi and one 3G network interface available in my system. and all communication is going through the default which is Ethernet. Now If I select wifi from the application, All communication within the application should go through wifi.
I searched a lot over net and figured out that using bind() function we can bind a specific IP address for communication. But, How can I achieve it in CEF3?
I am new to CEF3 and never written any networking software.
I have already gone through below links-
Using a specific network interface for a socket in windows
https://www.raymond.cc/blog/bind-windows-application-to-specific-network-adapter-with-forcebindip/
TCP/IP connection on a specific interface
I am writing cef3 application in win32/c++ so looking for the same.

Detect devices on local network for client-server connection in C++

I'm trying to implement an auto-connect feature for my Android application DroidPad, which is basically a TCP server running on an Android phone which the PC application connects to.
To make the process easier for the user, is there any way in (portable?) C++ to scan the IP addresses on the local subnet, possibly ones with a certain open port? I've tried using UDP broadcasting, but couldn't get it to work. I'm currently using the wxWidgets toolkit for GUI and libraries.
Any ideas?
I found a solution: wxServDisc. It uses mDNS (aka Zeroconf / Bonjour) to discover devices on a subnet, and is also based on wxWidgets.

Client and server

I would like to create a connection between two applications. Should I be using Client-Server or is there another way of efficiently communicating between one another? Is there any premade C++ networking client server libraries which are easy to use/reuse and implement?
Application #1 <---> (Client) <---> (Server) <---> Application #2
Thanks!
Client / server is a generic architecture pattern (much like factory, delegation, inheritance, bridge are design patterns). What you probably want is a library to eliminate the tedium of packing and unpacking your data in a format that can be sent over the wire. I strongly recommend you take a look at the protocol buffers library, which is used extensively at Google and released as open source. It will automatically encode / decode data, and it makes it possible for programs written in different languages to send and receive messages of the same type with all the dirty work done for you automatically. Protobuf only deals with encoding, not actually sending and receiving. For that, you can use primitive sockets (strongly recommend against that) or the Boost.Asio asynchronous I/O library.
I should add that you seem to be confused about the meaning of client and server, since in your diagram you have the application talking to a client which talks to a server which talks to another application. This is wrong. Your application is the client (or the server). Client / server is simply a role that your application takes on during the communication. An application is considered to be a client when it initiates a connection or a request, while an application is considered to be a server when it waits for and processes incoming requests. Client / server are simply terms to describe application behavior.
If you know the applications will be running on the same machine, you can use sockets, message queues, pipes, or shared memory. Which option you choose depends on a lot of factors.
There is a ton of example code for any of these strategies as well as libraries that will abstract away a lot of the details.
If they are running on different machines, you will want to communicate through sockets.
There's a tutorial here, with decent code samples.