Detect devices on local network for client-server connection in C++ - 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.

Related

Listen to UDP broadcast from a Ubuntu docker-container on Windows host

I have a C++ application that records the data from an external camera sensor. The sensor sends out UDP packets and it has it's own API. The API automatically scans the subnet and connects to the camera sensor. I know the IP address of the camera but there is no possibility to specify it manually using this API.
Unfortunately, I must use a Windows host machine to use my CPP application. I use CPP libraries that are only available for linux. Therefore I am constrained to use linux in a docker container on the Windows host. The camera API does not automatically find the device because it is not on the same subnet. The host network feature in docker would have solved this issue but it is not available on Windows.
Has someone been in a similar situation? or Can someone explain me how to get around this problem? I do not have much knowledge of networking.

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

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?).

UWP application refuses to receive data in P2P server part

I am trying to create P2P(UDP) windows 10 UWP application written in c++ using networking library written in C (tried both enet and libuv).
The problem is when the app is acting like client everything works as expected, but when I am testing the server part the application refuse to receive any events (connection in enet and messages from libuv). I tried the code from simple console applications and it works for both enet and libuv!
Also I added rules in the firewall to allow everything on the default port.
My question is, do I need to make additional configurations for the UWP application for receiving?
According to your description on your same thread in MSDN, the server and the client are on the same device.
According to the note of DatagramSocket official sample:
Network communications using an IP loopback address cannot normally be used for interprocess communication between a Universal Windows Platform (UWP) app and a different process (a different UWP app or a desktop app) because this is restricted by network isolation.
We cannot communicate a uwp app with other apps in a same machine. Not even with a loopback exemption. This is as design. If you use a c# console project as server and a uwp app as client, they may communicate successfully. But it need special steps (E.g. run the console as administrator) to let it work which you may happen to meet the requirements. Details you can reference this thread.

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.

How to acess COM port of remote system?

I Want to access the COM port present in the remote system from system. Any help would be appreciable.
I am using windows XP in both remote as well as local system.
The com0com project, and especially the com2tcp application should help you.
In conjunction with the Null-modem
emulator (com0com) the com2tcp enables
to use a COM port based applications
to communicate with the TCP/IP based
applications. It also allows
communication with a remote serial
port via the TCP/IP.
Personally, I use SerProxy, which makes that com port looks like telnet:
Serproxy is a multi-threaded proxy program for redirecting network socket connections to/from serial links, in cases where the remote end of the serial link doesn't have a TCP/IP stack (eg an embedded or microcontroller system). The proxy allows other hosts on the network to communicate with the system on the remote end of the serial link.
I also looked into com0com before, but I finally decide not to use it, as it requires a driver installation. Where as serproxy just need to be run. Another nice part is that if the com port is not being "used" remotely, I can still access it locally.
I've used Advanced Virtual COM Port to share a COM port remotely.
On the local PC, it creates a virtual COM port that mirrors the activity of a real COM port on the remote PC. The remote PC can be on a local network or on the Internet. (If on the Internet, you just have to make sure your firewalls allow the particular TCP ports through.)
I tried several programs to share a COM port remotely, but this was the only one I found that also shared the serial hardware handshaking signals. So we picked this one, and it worked great. We used it about 3 years ago, to access a Japanese CDMA modem dev board, sitting in Japan, from Australia.