Answer the question
In order to leave comments, you need to log in
What could be the problem when passing a container of "complex" objects over UDP?
There is, suppose, such a set of synthetic structures:
#include <cstdint>
#include <deque>
#include <algorithm>
struct Point;
struct Additional;
struct Track
{
uint64_t id;
std::deque<Point> points;
void appendNewPoint(int x, int y, Additional additional);
};
struct Additional
{
int dx;
int dy;
};
struct Point
{
Additional additional_data;
int x;
int y;
uint64_t id;
Track * parent;
Point * next();
Point * prev();
};
Point * Point::next()
{
auto& container = parent->points;
auto result = std::find_if(container.begin(), container.end() - 1, [this](Point& n) {
return this == &n;
});
return (result == container.end() - 1 ) ? this : &(*(result + 1));
}
Point * Point::prev()
{
auto& container = parent->points;
auto result = std::find_if(container.rbegin(), container.rend() - 1, [this](Point& n) {
return this == &n;
});
return (result == container.rend() - 1 ) ? this : &(*(result + 1));
}
void Track::appendNewPoint(int x, int y, Additional additional)
{
Point point = {additional, x, y, this->points.size(), this};
this->points.push_back(point);
}
std::unordered_map<uint64_t, Track> Tracks;
void *
std::unordered_map <uint64_t, Track>
Answer the question
In order to leave comments, you need to log in
https://www.boost.org/doc/libs/1_72_0/libs/seriali...
in Russian -> https://github.com/Danchetto/Boost.Serialization/b...
Question:
How can I transmit this over UDP using unix sockets?
After all, all this can be represented as a set of data, represented as void *, allocate half a megabyte for data, and send this whole thing to the server, and on the server to cast the received data back to std::unordered_map <uint64_t, Track>
or is it impossible to do this?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question