[ENet-discuss] Platforms other then Windows and *nix?

Lee Salzman lsalzman at gmail.com
Thu Aug 8 14:38:23 PDT 2013


First, the base time functionality exists because I have pretty much always needed it and used it for my purposes in games.

Second, as I stated, originally it was simply time(). It evolved into timeGetTime() because in that one case I wanted to avoid linking against, but I didn't think it warranted stubbing out over the issue as the code is rather simpler this way. Milliseconds are okayish there as well, though, for my purposes, game startup time is at best several seconds, so I preferred the longer cycle when convenient. If someone did manage to, for whatever reason, start up and connect on the exact same second, from the same ip and port, worst case scenario the connection might fail.

I feel no real need to defend the issue further and that's the last I will say on the matter.

On 08/08/2013 11:42 PM, Patrick Klos wrote:
> On 8/8/2013 4:18 PM, Lee Salzman wrote:
>> Not quite, enet_time_get() is for returning a running time counter, and is not really intended for providing a time-differentiated random seed. If you start up enet in quick succession making connections, then the random seeds can more easily accidentally overlap. The idea here is to get actual time in seconds so that on successive startups of enet the chance of collisions is much smaller. And it's intended that time() is pretty standard, and originally that's all that was used... Except that Win32 in its usual rebelliousness, doesn't quite like this without linking against more extra libraries, so I opted for timeGetTime() there. Chill out. It's not the end of the world.
>
> That doesn't make sense.
>
> First, let's look at the Windows version:  in both host.c and the enet_time_get() function in win32.c, you use timeGetTime(), so your results will be identical.  Of course, you do have the "timeBase" variable to offset your times from enet_time_get(), but how many people really use that?  For all practical purposes, Windows is going to have the same behavior either way.
>
> OK, so now let's look at the Unix version:  in host.c, you use the standard Unix time() function, which returns the number of seconds since Jan 1, 1970.  In unix.c, the enet_time_get() function uses gettimeofday(), and then builds a value which is essentially the number of milliseconds since midnight Jan 1, 1970.  So you're using whole seconds for the random seed, and milliseconds for the time counter.  I'm sure the chance of collisions is much greater (especially when you start up enet in quick succession) when you're using seconds for the random seed instead of milliseconds!?!  Please correct me if I'm wrong?
>
> Patric 


More information about the ENet-discuss mailing list