Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...
Posted
Updated 11-Apr-13 1:59am
v2

1 solution

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;
};
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900