Create a TCP socket to customize device

Hi everyone,
i’m new to the Arduino world and therefore I apologize in advance if I ask for things that may seem trivial. I am creating an interface for some devices in my house (in practice they are actuators that I can switch on and off via the network). I created the connection program in C ++ that works but I would like to assign in arduino, not knowing the syntax well can someone help me? below I show the code.


C++ code

#include <stdio.h>
#include <errno.h>
#include <string>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <cstring>
#include <unistd.h>
#include <iostream>
#include <unistd.h>
#include <sstream>
using namespace std;

// to compile gcc connect_PE_func.cpp -lstdc++ -c
char * connect_pe(int argc, char *argv[])
    int sockfd, n;
    int connected = 0;
    struct sockaddr_in servaddr;
    std::string serveraddr = argv[1];

    sockfd = socket(AF_INET, SOCK_STREAM, 0);

    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = inet_addr(serveraddr.c_str());
    servaddr.sin_port = htons(9761);

    connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));

    std::string pref_hex;
    std::string hex("0x");
    std::string test = argv[2];
    size_t numbytes = test.size() / 2;

    uint8_t command[numbytes];

    for (size_t w = 0, x = 0; w < numbytes; ++w, x += 2)
        pref_hex = hex + test.substr(x, 2);
        cout << pref_hex;
        command[w] = stoi(pref_hex, nullptr, 16);
        //cout << test.substr(x, 2);
        //cout << "\n";
        //cout << command[w];
        //cout << "\n";

    //uint8_t command[] = {0x26, 0x00, 0x00, 0x00, 0x26};
    int bytes_to_send = sizeof(command);

    send(sockfd, command, bytes_to_send, 0);
    uint8_t output_command[numbytes];
    recv(sockfd, output_command, bytes_to_send, 0);

    char test_out[10];

    for (size_t w = 0, x = 0; w < numbytes; ++w, x += 2)
        test_out[x] = (char)output_command[w];
        //cout << unsigned(test_out[x]);
    return test_out;

I forgot to write that I have Arduino Yun, sorry. So talent doesn't work with Arduino Yun

try to replace word Ethernet in the linked example with word Bridge