How Microsoft restricts developers on networking

Nowadays I’m interested in raw network programming which gives you ability to construct you building custom headers and makes sure that OS kernel does not modify these headers. I’ve started a VS.NET C++ console application (unmanaged) and typed several lines to test.

#include “stdafx.h”

int _tmain(int argc, _TCHAR* argv[])
int optval = 1;

setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&optval, sizeof optval);

return 0;

I got an error message;

Error 1 error C2065: ‘IP_HDRINCL’ : undeclared identifier ..

After some quick research I’ve come up to this solution. If you are interested in low level networking like me, you should have Unix based boxes instead of Microsoft. The reason is simple; restrictions. Raw socket programming is available in all Unix, and Linux OSs on the other hand MS based OSs is restricted to NT based ones. None of Windows 95, 98, 98SE supported raw sockets. It becames available on Windows from Windows 2000, Windows XP but with Windows XP SP2 this feature is disabled. Quick summary from Microsoft’s specification for this issue:

The Windows implementation of TCP/IP still supports receiving traffic on raw IP sockets. However, the ability to send traffic over raw sockets has been restricted in two ways:

* TCP data cannot be sent over raw sockets.
*UDP datagrams with invalid source addresses cannot be sent over raw sockets. The IP source address for any outgoing UDP datagram must exist on a network interface or the datagram is dropped.

Microsoft encourages the developers to use their products but restricts them to full access. There is a conflict but this is Microsoft. They are doing their best !!!