Skip to content
Snippets Groups Projects
Commit fa2c0da3 authored by Benny Baumann's avatar Benny Baumann
Browse files

add: UDP socket tests

parent 8eca5b3e
No related branches found
No related tags found
1 merge request!1First unit tests
Pipeline #7445 failed
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
#include "net/udp_client.hpp"
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
namespace rmrf::net {
bool udp_test_successful = false;
const char* udp_test_string = "TEST UDP PACKET";
void udp_test_cb(const udp_packet<pkg_size>& data, socketaddr& source) {
if (strcmp(data.raw, udp_test_string) != 0)
udp_test_successful = true;
}
void run_udp_test() {
udp_client sender{get_first_general_socketaddr("localhost", 9862)};
const socketaddr destination_address = get_first_general_socketaddr("localhost", 9863);
udp_client receiver{destination_address, udp_test_cb};
udp_packet<1024> data;
strncpy(data.raw, udp_test_string, sizeof(udp_test_string) + 1);
sender.send_packet(destination, data);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment