Click here to Skip to main content
11,929,481 members (53,342 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET COM serialport
I want to open a single com port from two or more applications. can anyone provide a some code or any link for achieving this in .net? I am searching the internet from last two days but, could not find any solution. I know, it is possible, because i have some applications that do this work. But, i have to write this functionality in my own application.

Thanks in advance.
Posted 17-Jan-13 21:25pm
Edited 17-Jan-13 21:29pm
—SA 18-Jan-13 2:33am
i have to trace the communication between an existing application and some manufacturing machine.
lukeer 18-Jan-13 2:56am
Say you had the monitoring software already working, you could as well solder some special man-in-the-middle-three-plug-wire to listen to communication in one direction or the other.
Jochen Arndt 18-Jan-13 3:09am
To trace the communication, use a serial port sniffer / monitor. Using the last three/four words you will get a lot of search hits including free utilities. An example application in C++ can be found here at CP: It's not .NET but it explains how monitoring can be done. 18-Jan-13 3:19am
thanks but, it could not work. 18-Jan-13 3:19am
it cannot open an already open port.
Jochen Arndt 18-Jan-13 3:32am
An already opened port can't be opened a second time. This can't be circumvented. Therefore, all software sniffers must be started before the port is opened.

What are these 'some applications' that claim to can do that? 18-Jan-13 4:23am
one of them is HHD Serial Port Emulator
Jochen Arndt 18-Jan-13 5:14am
Thank you for the information. I just tested it and it can monitor opened connections. So you are right that sniffing can be done this way. But it is not done by openening a port a second time (the Windows API CreateFile function used to open serial ports will fail when the port is already opened).

Because this is interesting, I googled a little bit:
From the above:

I hope this helps and you have some kind of success. 21-Jan-13 0:06am
Thanks Jochen, did u try this code? Does it work for you?
Jochen Arndt 21-Jan-13 3:28am
No, I did not tried it. It's too complex for a quick implementation. 21-Jan-13 7:37am
I feel the same and don't have time to get into the depth at this time.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can not have more than one process opening a com port. If port is opened by a process, other process will simply not be able to open it. Best bet is to use simple TCP/IP, open the port from a server program, from other applications, interact with the server.
Comments 18-Jan-13 3:02am
AS i already said, i am able to open a port multiple times using a third party application. but i want to do it in my own code to make it user friendly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100