windows winsock2 fun.
Thu, Oct 7, 2004I've been working with some legacy (vc6) code which uses various windows specific libraries. Most importantly winsock2, which defines never versions of the original winsock functions. That is important to note, as windows.h would very much like to include winsock itself. Thats winsock not winsock 2, which is a rather important distinction. The simple way around this is to include the winsock2 header before the windows header. Which annoyingly enough is the oposite of what this site would have you believe. This may be due to my compiler choice, as I am using visual studio 2003.
And now for something only slightly different! If you are doing c-string operations use strlcpy and strlcat, if they aren't implemented for your platform write them yourself. They can save you a world of headaches. The short of it is that they properly enforce null termination on the resultant strings. This is pretty important, unless of course you want your code to be another example of Smashing The Stack For Fun And Profit. Lets not forget Exception handler exploits, but thats another problem altogether.