Reputation: 786
Looking for the best way to implement a C# program that will be able to listen and send across TCP (a client server?). I'm fairly new to networking stuff so I'll give a brief explanation of what I want to do, and how I thought to do it.
What I want: Ok, so the GUI I've made has a text box and 2 buttons (more complex in actuality, but if I can get this to work I can get mine to work)the text box will hold a value read from the TCP, for me its a voltage (integer) read from a remote power monitoring system. On the GUI the user should be getting up-to-date refresh of the current voltage, AND the buttons are used to increase or decrease the voltage by 1. SO the system needs to always be listening, and be able to talk.
How I thought may work: Have the program always listening for an updated value to put in txt box. If the user presses a button, the button interrupt will make TCP 1)stop listening, 2)send increase/decrease request, 3)resume listening.
My Questions: 1)is my idea on how to structure it ok? or is there a more efficient/simpler/"better" way of going about this?
2) I'm not so sure on how to set up a Client/Server/Client-Server in TCP on C#, is there any reccomended documentation/tutorials?
*For testing purposes I'll just be communicating between 2 instances of the GUI on my 1 PC.
Upvotes: 1
Views: 341
Reputation: 5369
I suppose your idea is fine. You are right to believe that you should go with the client-server architecture. You have to be carefull though. You have to define which part is the server and which is the client. Supposing that the GUI is the server and the remote sensor is the client, this means that the client power monitoring system should send the data to the TCP server.
I would suggest this tutorial.
Hope I helped!
Upvotes: 1