See http://msdn.microsoft.com/en-us/library/398ax69y.aspx
The rand function returns a pseudorandom integer in the range 0 to RAND_MAX (32767).
As for rand() in win32select.c, I don't think values between 0 and 32767 are expected while the max TCP port number exceeds this limit.
As for rand_init(50000) in test/test-time.c, it will be rand()%50000 and yield a value between 0 and 32767, which does not work as expected either.