我正在尝试通过套接字发送原型,但出现分段错误。有人可以帮忙告诉我这个例子有什么问题吗?
文件.proto
message data{
required string x1 = 1;
required uint32 x2 = 2;
required float x3 = 3;
}
xxx.cpp
...
data data_snd, data_rec;
//sending data to the server
if (send(socket, &data_snd, sizeof(data_snd), 0) < 0) {
cerr << "send() failed" ;
exit(1);
}
//receiving data from the client
if (recv(socket, &data_rec, sizeof(data_rec), 0) < 0) {
cerr << "recv() failed";
exit(1);
}
感谢您的帮助和回复-