Why can't my AVR microcontroller running Zephyr connect to a remote server using TCP?

hey guys, I'm trying to send log data to a remote server using TCP on my AVR microcontroller running Zephyr. Despite setting up the network interface and writing the TCP client code, I can't establish a connection to the server.
so far I have configured the network interface in prj.conf, and also implemented the TCP client to connect and send data.

Code Snippet:
#include <zephyr.h>
#include <net/socket.h>
#include <logging/log.h>

LOG_MODULE_REGISTER(main);

void main(void) {
    int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (sock < 0) {
        LOG_ERR("Failed to create socket");
        return;
    }

    struct sockaddr_in server_addr;
    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(12345);
    inet_pton(AF_INET, "192.168.1.100", &server_addr.sin_addr);

    int ret = connect(sock, (struct sockaddr *)&server_addr, sizeof(server_addr));
    if (ret < 0) {
        LOG_ERR("Failed to connect to server: %d", ret);
        close(sock);
        return;
    }

    char msg[] = "Log data";
    ret = send(sock, msg, strlen(msg), 0);
    if (ret < 0) {
        LOG_ERR("Failed to send data: %d", ret);
        close(sock);
        return;
    }

    LOG_INF("Data sent to server");
    close(sock);
}


The TCP client fails to establish a connection to the server. What could be causing this issue? If successful, I expect to see the log data sent to the remote server. @Middleware & OS
Was this page helpful?