方法一:
发送端:
-------------------------------------------------------
struct ST_HISTORY
{
int EcgValue;
int EegValue;
Char Alarm;
CString str;
int Wave[3][20];
};
ST_HISTORY stHistory;
char szSend[MAX_LENGTH] = {0};
memcpy(szSend, &stHistory, sizeof(stHistory));
send(socket, szSend, strlen(szSend), 0);
接收端:
------------------------------------------------------------
char szRecv[MAX_LENGTH] = {0};
int nRecv = recv(socket, szRecv, MAX_LENGTH, 0);
szRecv[nRecv] = '/0';
ST_HISTORY stHistory;
memcpy(&stHistory, szRecv, sizeof(stHistory));
方法二:
直接传送和接收结构体
struct tagStruct{
//
}SendStruct;
send(socketID,(char*)&SendStruct,sizeof(SendStruct),0);
struct tagStruct{
//
}RcevStruct;
recv(socketID,(char*)&RecvStruct,sizeof(RecvStruct),0);