客户端和服务器结构的长度 [英] length of client and server structure

查看:142
本文介绍了客户端和服务器结构的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

这是一个微不足道的问题,但如果有人回答这个问题,我将非常感激,

 server_length = sizeof(struct sockaddr_in) ; //在客户端



 client_length =(int)sizeof(struct sockaddr_in); //在服务器端





我知道上面的语句分别返回客户端和服务器的长度,但我很难时间理解为什么我们需要这些...... :(



我真的很感谢你的帮助......

解决方案

结构的大小通常用作结构版本的标志。通常用于在结构的末尾添加新成员。



查看此样本





 struct V1 
{
int h;
};

struct V2
{
int h;
int v;
};


hey,
this is a trivial question but I shall be really grateful if somebody answers this,

server_length = sizeof(struct sockaddr_in);//On client side 


client_length = (int)sizeof(struct sockaddr_in); //On server side 



I do know that the above statements return the length of the client and server respectively but I am having a hard time understanding as to why do we need these....:(

I would really appreciate your help...

解决方案

the size of a struct is often used as flag of the version of the struct. It is common use to add new members at the end of the struct.

check this sample


struct V1
{
  int h;
};

struct V2
{
  int h;
  int v;
};


这篇关于客户端和服务器结构的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆