Hi,
I have been trying for the past 2 days to design a simple application in C# to read from serial Port continuously and write the data as it is; say a string, to an IP:port on the machine. And later I want to read from that IP:port and use it to expose on a web service.
This is my design(Thought)
1. SerialPort Reader fetches data from SerialPort --> writes that data continuously to an IP:port using a socket ( this app keeps running continuously as a service)
2. A webservice that reads the data from the said IP:port and exposes it on another port for web access.(Say for an angularjs application which would query using json and display the obtained data on web).
Since I am new to Network programming I am unable to comprehend the communication technique.
Please suggest if I am right in thinking the above.
I am able to read from serial port but When I tried to write to 127.0.0.1:8888 it throws an exception saying that the machine actively refused connection. On a further search, I learned that you need a listener on that port for you to be able to write to that port.
But my idea is simple
-> 1st service keeps reading data from SerialPort and keeps writing to a IP port irrespective of whether it is read or not.
and
-> 2nd service exposes that data to world on request (a web api).
is it possible? please give me a direction which will make me meet my requirement.
Thanks in advance
Ganesh.
What I have tried:
Techniques mentioned in these sites and many more:-
A TCP/IP Server written in C#[
^]
c# - TCP IP Listener in windows Service - Stack Overflow[
^]
How to C# Socket programming[
^]