HOWTO: Open TCP and UDP from Win32 ApplicationsID: Q195316 
  | 
You might want to enable your Win32 application to open the UDP or TCP device objects. By doing this, you enable the application to open a TDI control channel to UDP or TCP. By default, there is no symbolic links created to TCP or UDP. The Win32 application must call DefineDosDevice to create a symbolic link before calling CreateFile().
The following sample code demonstrates how to open the TCP device object:
   #include <windows.h>
   void main()
   {
   HANDLE  handle = NULL;
   BOOL      success = NULL;
   char    deviceName[] = "TCP";
   char    targetPath[] = "\\Device\\TCP";
   char    completeDeviceName[] = "\\\\.\\TCP";
   // 
   // First create a symbolic link.
   // 
   success = DefineDosDevice (DDD_RAW_TARGET_PATH,
                    deviceName,
               targetPath
               );
   if (!success) {
   MessageBox(NULL,"DefineDosDevice failed","Notice",MB_OK);
   }
   // 
   // Then call CreateFile().
   // 
   handle = CreateFile(completeDeviceName,
             GENERIC_READ | GENERIC_WRITE,
             0,
             NULL,
             OPEN_EXISTING,
             FILE_ATTRIBUTE_NORMAL,
             NULL
             );
   if (handle == INVALID_HANDLE_VALUE) {
      MessageBox(NULL,"CreateFile failed","Notice",MB_OK);
   } else {
      MessageBox(NULL,"CreateFile succeded","Notice",MB_OK);
      CloseHandle(handle);
   }
   } 
Keywords          : kbDDK kbNDIS kbNTOS310 kbNTOS350 kbNTOS351 kbNTOS400 kbWinOS2000 
Version           : 
Platform          : 
Issue type        : kbhowto 
Last Reviewed: March 8, 1999