Microsoft KB Archive/195316

{|
 * width="100%"|

HOWTO: Open TCP and UDP from Win32 Applications

 * }

Q195316

-

The information in this article applies to:


 * Microsoft Win32 Device Driver Kit (DDK) for Windows NT, versions 3.1, 3.5, 3.51, 4.0, 5.0

-

SUMMARY
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.

MORE INFORMATION
The following sample code demonstrates how to open the TCP device object:

Sample Code
  #include 

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 kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000

Issue type : kbhowto

Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT310 kbWin32DDKNT350 kbWin32DDKNT351 kbWin32DDKNT400 kbWin32DDKNTSearch