Graindor
Posts: 2
Joined: Mon Oct 08, 2018 1:49 pm

C++ TCP (PC & RPi)

Mon Oct 08, 2018 1:58 pm

Greetings,

I have a C++ program which runs on Raspberry Pi, while it is running I want to change the variables so that when the program runs next time it runs with the updated values. I have a file which updates the values in my Windows PC.
I have learned that one of the methods to do so in Socket Programming and make the PC and RPi communicate through sockets.
I want to achieve this in C++ (communication between Raspberry Pi and PC during time) and I'm having hard time to find online resources. Please point me towards the resources or any example which does something similar.

Thanks.

User avatar
rpdom
Posts: 12856
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: C++ TCP (PC & RPi)

Mon Oct 08, 2018 7:13 pm

There is nothing Pi specific in what you want to do, so just search the internet for Linux Socket C++ and you should be able to find something that will do what you want.

Heater
Posts: 9974
Joined: Tue Jul 17, 2012 3:02 pm

Re: C++ TCP (PC & RPi)

Tue Oct 09, 2018 3:57 am

One of the nicest ways to make a TCP/IP client and server is to use the networking API that comes with Qt:
https://www.bogotobogo.com/Qt/Qt5_QTcpS ... Server.php

Qt is a toolkit for making graphical user interfaces but you can use the networking and other parts of Qt with command line programs as well.

This is a cross-platform solution so you can develop on a Win PC or Mac and deploy on the Pi.

Graindor
Posts: 2
Joined: Mon Oct 08, 2018 1:49 pm

Re: C++ TCP (PC & RPi)

Tue Oct 09, 2018 6:09 am

Thanks @rpdom & @Heater

grininmonkey
Posts: 92
Joined: Mon Jul 30, 2018 3:44 pm

Re: C++ TCP (PC & RPi)

Thu Oct 11, 2018 2:07 pm

I used the following link recently as a starting point or example for sockets in C... I am just experimenting with C via editing files in Vim... so not using QT or the like..... yet

https://www.geeksforgeeks.org/socket-programming-cc/

Return to “C/C++”