I have a class whose object I pass through the socket via read() and write() . Among the class fields are standard type fields ( int and char ) and a field of type std::string .
I initialize the fields of the class, the field of the string type initializes with a string constant (maybe this is important). After transferring to the server, I transfer the field values to the terminal. All fields are displayed correctly, but when I display a string field, a segmentation error occurs.
Therefore, the question is: how to transfer the type of string so that it is displayed correctly?