From: Brian D. <br...@de...> - 2005-07-15 08:37:26
|
Markus Selve wrote: > I really want only to use htonl(), no real operations with socket. I tried > it without WSAStartup() and it works. Even if you only use htonl() I still recommend that you call WSAStartup(). If it works despite this you are simply lucky and there is no guarantee that it will continue to work with future versions of Windows. Depending on undefined behavior is not a good practice in any programming environment. MSDN says explicitly that you must do this: The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the version of Windows Sockets required and retrieve details of the specific Windows Sockets implementation. The application or DLL can only issue further Windows Sockets functions after successfully calling WSAStartup. <http://msdn.microsoft.com/library/en-us/winsock/winsock/wsastartup_2.asp> Brian |