What is sa_family_t

I follow the Beej Guide to Network Programming and I use VC ++ 2010, but when I copy the insertion of structures into my program, some types appear as invalid identifiers. For instance:

u_int32_t appeared, and after some searching, I found out that these are old types from the C language around 1999. I could just include stdint.h, but that would require me to remember what they meant. Instead, I used a standard int , which has a length of 32 bits (4 bytes), and for the rest - 64 bits (8 bytes), I used a long long int .

In any case, I judge to the last syntax error, and he says that sa_family_t is an invalid identifier. I have no idea what should have been and what to look for, nothing happened. What is my problem, I do not know what I should specify for the type identifier for this.

Another thing that bothers me is: char __ss_pad1[_SS_PAD1SIZE]; Thing SS_PAD1SIZE also red as invalid.

+4
source share
1 answer

sa_family_t must be an unsigned integer. Windows header files do not comply with this standard. Winsock.h defines the sockaddr structure as follows:

 struct sockaddr { u_short sa_family; /* address family */ char sa_data[14]; /* up to 14 bytes of direct address */ }; 

So, to compile your code, you will need typedef sa_family_t yourself.

+5
source

All Articles