I'm following Beej's Guide to Network Programming, and I'm using VC++ 2010, but when I copy paste the structs into my program, some of the types come up as incorrect identifiers. For example:
u_int32_t
came up as that, and after some searching I found out those are old types from the C language circa 1999. I could have just included stdint.h, but that would require me to remember what they meant. Instead I used the standard int
, which is 32 bits long (4 bytes), and for the other ones which are 64 bits long (8 bytes), I used long long int
.
Anyways, I'm narrowing down to my last syntax error and it says sa_family_t
is an invalid indentifier. I don't have a clue what its supposed to be and searching has turned up nothing. That's my problem, I don't know what I should specify for a type identifier for that.
Another thing that's bothering me is this: char __ss_pad1[_SS_PAD1SIZE];
The SS_PAD1SIZE
thing comes up in red as invalid too.
sa_family_t should be an unsigned integer. The Windows header files don't conform to that standard. Winsock.h defines the sockaddr struct 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're going to need to typedef sa_family_t yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With