Skip to content

TCP client unable to send multiple messages in a loop #5

@Slluxx

Description

@Slluxx
    const int invalid_protocol_return = 1;
    const int invalid_sockettype_return = 2;
    const int udp_protocol = 1;
    const int tcp_protocol = 2;
    const int client_socket = 1;
    const int server_socket = 2;

    u_short socket_port = 5000;
    std::string destination_ip = "192.168.2.182";

    TCPClient client(socket_port, destination_ip);
    int connection_status = client.make_connection();
    // Return if there is an issue binding
    if (connection_status)
    {
        return connection_status;
    }
    else
    {
        while (true)
        {
            client.send_message("Testmessage\n");
            client.send_message("Testmessage2\n");
            svcSleepThread(1000000000ull); // 5s
        }
    }

this code sends Testmessage but not Testmessage2, nor does it loop. it looks like it just stops executing.

EDIT: figured out why.

if (recv(m_socket, server_reply, 2000, 0) == SOCKET_ERROR)

blocks code execution untill something is recieved, even tho i never wanted to recieve anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions