我試圖通過UDP套接字發送結構,我收到DRB_count的值正確但無法接收KenbStar的值。我究竟做錯了什麼?我使用同一臺機器,在客戶機和服務器上使用同一端口回送ip 127.0.01。通過UDP套接字C++發送結構
客戶端:
typedef struct tseTargetCellInformation{
UInt8 DRB_count;
UInt8 *KenbStar;
}tTargetCellConfiguration;
trecTargetCellConfiguration *rx_TargetCellConfiguration_str;
rx_TargetCellConfiguration_str = (trecTargetCellConfiguration*)malloc(sizeof(trecTargetCellConfiguration));
send_TargetCellConfiguration_str->DRB_count=1;
send_TargetCellConfiguration_str->KenbStar = (UInt8*) malloc(1);
send_TargetCellConfiguration_str->KenbStar[0]= 0x5b;
sendto(sd, (char *) (send_TargetCellConfiguration_str), sizeof(tTargetCellConfiguration), 0, (struct sockaddr *)&server, slen)
服務器:
typedef struct tseTargetCellInformation{
UInt8 DRB_count;
UInt8 *KenbStar;
}tTargetCellConfiguration;
rx_TargetCellConfiguration_str->KenbStar = (UInt8*) malloc(1);
recvfrom(sd, (char *) (rx_TargetCellConfiguration_str), sizeof(trecTargetCellConfiguration), 0, (struct sockaddr*) &client, &client_length);
這看起來不像'C++'。 – 2013-03-01 11:39:42