q***z 发帖数: 934 | 1 Hello I am a newbie on network programming.
I am trying to receive a packet
if((numbytes = recvfrom(udp_fd1, buf, MAXLEN-1, 0,(struct
sockaddr*)®ister_addr, &addr_len))==-1){
fprintf(stderr, "error in recvfrom.\n");
exit(1);
}
The packet I am receiving has the following possible structure.
typedef struct struct_CN
{
unsigned char magicA;
unsigned char magicB;
unsigned short msgLen;
} CN;
typedef struct struct_Cc
{
CN msgHeader;
uns | n******t 发帖数: 4406 | 2 How do you send the structure,
generally you can not send raw C structure on
network. Better encode it to a network message
and send it.
【在 q***z 的大作中提到】 : Hello I am a newbie on network programming. : I am trying to receive a packet : if((numbytes = recvfrom(udp_fd1, buf, MAXLEN-1, 0,(struct : sockaddr*)®ister_addr, &addr_len))==-1){ : fprintf(stderr, "error in recvfrom.\n"); : exit(1); : } : The packet I am receiving has the following possible structure. : typedef struct struct_CN : {
|
|