UDP/TCP port issue

My So:

  • Ubuntu 22.04
  • The last one on QGround Repository (4.2.0)

Issue:

  • I want to make an API that get data from QGC , battery status, gps, etc. I what QGC to send data via port to that API.
  • I made a simple code in c++ that listen a port and print in console the info that is in the buffer. Let say that this program is mi server and QGC mY client.
    -In QGC i made this connection:
    image
    When i start the server it conect to the QGC port that is in the picture. But in the server side the data is not showing.
    -The server work properly ( i tried “telnet 127.0.0.1 port” and it works).

I read something about MAVSDK and MavLink Router, bu not sure if that whill help. I understand that this two software are from connecting Ground Stations to an UAV. I made my server without QT Frame work. Is that a problem?

Server Code:

#include
#include
#include
#include <unistd.h>

#include <sys/socket.h>

#include <netinet/in.h>
#include <arpa/inet.h>

int main() {

int PORT = 8080;

int Server_socket,Client_socket;

struct sockaddr_in Server_addr, Client_adrr;

socklen_t Client_socket_len;

//Creacion de el soket del servidor

Server_socket = socket(AF_INET,SOCK_STREAM,0);

if (Server_socket == -1){
    std :: cerr << "Error al crear el socket del servidor\n";
    return -1;
}

//Definir IP y puerto del servidor

memset(&Server_addr,0,sizeof(Server_addr));
memset(&Client_adrr,0,sizeof(Client_adrr));


Server_addr.sin_family = AF_INET;
Server_addr.sin_addr.s_addr = INADDR_ANY;
Server_addr.sin_port = htons(PORT);

//Conectar el socket del server a la direccion

if (bind(Server_socket, (struct sockaddr *) &Server_addr, sizeof(Server_addr)) < 0) {
    std::cerr << "Error conectando socket\n";
    return -1;
}


/* SOlO CONEXIONES TCP*/
if(listen(Server_socket,1)){
    std::cerr << "Error al preparar para recivir conexiones ";
}

Client_socket_len = sizeof(Client_socket);

Client_socket = accept(Server_socket,(struct  sockaddr *) &Server_addr,&Client_socket_len);
if (Client_socket == -1){
    std :: cout << "Error al aceptar conexion del cliente";
}
std :: cout << "Conexion recibida desde : " << inet_ntoa(Client_adrr.sin_addr)<< ":" << ntohs(Client_adrr.sin_port)<< "\n";


char Buffer[100000];

while (true)
{ 
    //memset(&Buffer,0,sizeof(Buffer));

    // TCP//
    int BytesRecividos = read(Client_socket,Buffer,sizeof(Buffer)); 

    std :: cout << Buffer; 

}


close(Client_socket);

return 1;

}

I am missing something? How Could i fix this problem?