3 ms·
> socklen_t – if your OS doesn’t have socklen_t, it’s either int or size_t. But OpenSSL does horrible contortions to define its own. If the size of socklen_t ch
by bodyfour 12y ago
> socklen_t – if your OS doesn’t have socklen_t, it’s either int or size_t. But OpenSSL does horrible contortions to define its own. If the size of socklen_t changes while your program is running, openssl will cope.
This doesn't surprise me; I've had to do runtime detection of socklen_t before. There have been 64-bit platforms (old HP/UX I think?) where different versions of the system libraries had differing opinions about sizeof(socklen_t) when you called accept(). On a little-endian platform this would be ignorable (just always reserve 64 bits and pre-zero it) but on big endian you had to do something like:
uint64_t addrlen = 0;
rv = accept(sock, &addr, (socklen_t *) &addrlen);
if ((addrlen & 0xFFFFFFFF) == 0)
addrlen >>= 32;
...in order for your binary to run on all systems. Fun times.