The C++ Standard newer than C++98 states that vector memory is contiguous.
E.g. see
c++ - Is it safe to assume that STL vector storage is always contiguous? - Stack Overflow[
^] and
vector - C++ Reference[
^].
You could do something like this:
class MyClass {
private:
typedef unisnged char Byte;
enum { MY_MESSAGE_SIZE = 1024 };
...
std::vector<Byte> buffer;
...
public:
MyClass()
: ...
, buffer(MY_MESSAGE_SIZE) , ...
{ ... }
void doSomethingUseful(...) {
...
result = recvfrom(udpsocket, &(buffer[0]), MY_MESSAGE_SIZE, 0, (sockaddr *)&si_other, &slen);
...
}
};
Cheers
Andi