#509 closed task (fixed)
Network: Should call enet_initialize
Reported by: | Philip Taylor | Owned by: | |
---|---|---|---|
Priority: | Nice to Have | Milestone: | |
Component: | Core engine | Keywords: | |
Cc: | Patch: |
Description
Documentation for enet_initialize
says:
Must be called prior to using any functions in ENet.
We don't call it at all. We probably should. (It does nothing on Unix, but calls WSAStartup
and timeBeginPeriod
on Windows; need to make sure that doesn't interfere with our own wsock or timer code.)
Change History (5)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
ENet calls WSAStartup with version (1, 1)
, wsock.cpp calls it with version 0x0002
. What happens when it's called multiple times with different versions? Will either piece of code break if it gets an unexpected version of Winsock?
comment:3 by , 14 years ago
0x0002 is 2.0, which is the newer ws2_32.dll. 2.0 is a superset of 1.1, and introduces functions we use (getaddrinfo). However, I'd be surprised to see ws2_32 restrict the functions that can be called based on the requested version:
1) wsock32.dll appears to be implemented in terms of ws2_32 (note 25 KB file size and dependency on ws2_32)
2) see last post in http://www.mofeel.net/40-microsoft-public-win32-programmer-networks/7031-2.aspx
If there does turn out to be trouble, then the proposed solution is to change enet's request to 2.0 - 1.0 and 1.1 are ancient and we don't support Win9x anyway.
comment:4 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Some background info:
our wsock.cpp contains some magic to automatically call WSAStartup when the wsock DLL is loaded (via delay-load notification). MSDN says WSAStartup can be called multiple times.
timeBeginPeriod can only decrease the timer interrupt period - requests for a lower frequency are ignored. If our timer backend decides to use timeGetTime, it'll also set timeBeginPeriod(1). There is no harm or conflict (other than increased interrupt overhead).
So: it's fine to call enet_initialize, but currently unnecessary (which is why it works without).