Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Slluxx opened this issue Oct 24, 2022 · 0 comments
Open

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

Slluxx opened this issue Oct 24, 2022 · 0 comments

Comments

@Slluxx
Copy link

Slluxx commented Oct 24, 2022

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant