You can connect to a COM device using the SerialPort
class in C#.
Can multiple programs connect to one COM device at the same time?
Two or more programs connect to SerialPort.Open()
I wonder if there is a way to connect at the same time without SerialPort.Close()
.
Asked
Active
Viewed 259 times
0

41686d6564 stands w. Palestine
- 19,168
- 12
- 41
- 79

ceastgun
- 81
- 8
-
1If this is windows. no, you will have to write a single application and have your 2 programs communicate with it – TheGeneral Oct 12 '20 at 02:06
-
You need to think really hard about how that device will handle two arbitrary, interleaved streams of data. – Jonathon Reinhart Oct 12 '20 at 02:35
1 Answers
1
As mentioned in the comments - write a proxy service program to connect to the COM device, other programs would be able to get the data from the proxy, a simple flow would be a Socket
server that accepts 1 or more Socket
client connections.
The server would be responsible for Serial communication with the COM device and sending the data back to the clients, since there's a hefty amount of code involved, and plenty of examples online on how to create an Async Socket server and Async Socket clients, here are some excellent examples without putting it all down here in the answer:
Asynchronous Server Socket Example

kshkarin
- 574
- 4
- 9