I finally found out how I can do it using com0com along with the tool com2tcp (which is part of the com0com project). The approach is described in this document: http://com0com.sourceforge.net/doc/UsingCom0com.pdf The com0com project is a really useful and amazing thing!
Basically, the idea is to create two pairs of virtual COM ports on the machine. In my case they are: COM7 <-> COM8 and COM9 <-> COM10. Then, using com2tcp utility, I redirect the data transmission between COM8 and COM10 via TCP. In two console windows I start the com2tcp once as server, once as client (as described in the document above). In particular, I use com2tcp --telnet \\.\COM8 12345
(where 12345 is some TCP port number) and com2tcp.exe --telnet \\.\COM10 1.2.3.4 12345
(where 1.2.3.4 is my machine's IP address). COM7 and COM9 are used by both instances of my application, so that the communication goes like this: PROCESS1 <-> COM7 <-> COM8 <---- TCP ----> COM10 <-> COM9 <-> PROCESS2
. Then, when both application instances are running, I just stop the com2tcp process by pressing CTRL+C
in the console - and that breaks the port-to-port communication exactly as a cable break would do! In this way I could easily simulate and debug the behavior as I needed.