socklen_t is a strange typedef for the size of a struct sockaddr in accept(), getpeername(), and connect().

The reason for this typedef is that in BSD, those functions took an int*, and the POSIX people screwed it all up when they decided to make such arguments point to an integer of (potentially) another size, under a new typedef. But since we're dealing with pointers here, you can't change the size of the pointer type passed without severely breaking code written for BSD. So, this typedef is rather useless, as any sane library will have to make socklen_t the same as int.

I don't know what the current situation is with the POSIX folks, but I would hope they got their act together and made it require this typedef to be an int. I personally would deprecate it entirely and return to the tried and true int seen in the BSD prototypes.

Log in or register to write something here or to contact authors.