avatar
One network C question# Programming - 葵花宝典
q*z
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*)&register_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
avatar
n*t
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*)&register_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
: {

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。