Thoughts of a random geek

Tuesday, November 18, 2008

Windows Sockets

MSDN on winsock

CodeProject C++ skeleton using winsock

Of note: An application must call the WSACleanup function for every successful time the WSAStartup function is called. This means, for example, that if an application calls WSAStartup three times, it must call WSACleanup three times. The first two calls to WSACleanup do nothing except decrement an internal counter; the final WSACleanup call for the task does all necessary resource deallocation for the task.

Also: If you include windows.h and winsock2.h, you have to put winsock2 first. Otherwise, windows.h will include winsock.h and you'll get a plethora of redefinition errors from winsock2.h.

No comments: