title: Windows COM port for IPC
body: <p>Can the Windows COM port be used by two programs running on the same PC for inter process communication? Our ultimate goal is to write a program which communicates over COM port to control a hardware. Since the hardware is not available we want to emulate the hardware in a program which reads from a virtual COM port and responds.</p>
  
  <p>A trivial emulator would be a program which waits for bytes to be read from the COM port and responds by writing on to the COM port. To start with the values of these messages can be hardcoded.</p>
  
  <p>So what I do is I have two programs written in C/C++ using the <code>ReadFile</code>, <code>WriteFile</code> functions given by windows to read and write over the file. This approach will not work because of access conflict. Hence I was wondering if our approach for the emulator itself is wrong.</p>
  
  <p>I am new to Windows based programming though I have programming experience in other areas. Any help would be greatly appreciated.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Solution:</p>
  
  <ul>
  <li>Installed Virtual Serial Port Driver 7.1 by Eltima Software (trial version)</li>
  <li>Added a pair of virtual ports (e.g. COM1 and COM2)</li>
  <li>The controller program communicates through COM1</li>
  <li>The emulator program communicates through COM2</li>
  <li>Eltima software takes care of transferring the data between the two ports</li>
  </ul>