TcpClient
and/or Socket
classes. The first is a simplified wrapper for the second. If the device needs to connect to your machine, look at the TcpListener
class.Thank you and I will check my Codes.If you're trying to connect to the device, you should look at theTcpClient
and/orSocket
classes. The first is a simplified wrapper for the second. If the device needs to connect to your machine, look at theTcpListener
class.
It connected through LAN, there is no USB its a PLC device this device transmit a data if you tap 1 of those button sir. It will transmit a data, and that data I need to get it through textbox etc.What is the other device, and how is it connected? Usb, Lan, Wireless, explain?
I don't understand. In your original post you were asking how to transmit data to the the device, but in your reply above, you are saying that the device will be the one that will be transmitting data. This makes a difference between you needing aIt connected through LAN, there is no USB its a PLC device this device transmit a data if you tap 1 of those button sir. It will transmit a data, and that data I need to get it through textbox etc.
TcpClient
to be a client of the device acting as a server, or if you need a TcpListener
so that you'll the server for the device acting as a client.Oh sir sorry for that if you misunderstood me. All I wanna know is I need to connect that device that's all I'm sorry sir.I don't understand. In your original post you were asking how to transmit data to the the device, but in your reply above, you are saying that the device will be the one that will be transmitting data. This makes a difference between you needing aTcpClient
to be a client of the device acting as a server, or if you need aTcpListener
so that you'll the server for the device acting as a client.
Or is the idea for you to act as a client of the device, and once you are connected, the device will send data to you?
Ok sir Thank you.Regardless if its a stream going in or out, you will need to read it.
One other thing I didn't mention, is that you might also be faced with a blocking exception due to the port already being in use especially if your device can already listen for traffic. Take that into account too.
If this is your first time doing any kind of networking code, I highly recommend going up the learning curve first where you you control both the client and server. Only after you've got a good handle on how that interaction works, then start doing the one sided work involved here where your code will either be the client or the server.Its too hard because its my first time to encounter this kind codes. So that's why I really need help thank you.
Thank you sir.If this is your first time doing any kind of networking code, I highly recommend going up the learning curve first where you you control both the client and server. Only after you've got a good handle on how that interaction works, then start doing the one sided work involved here where your code will either be the client or the server.
For a quick overview of what you need to learn, consider reading these:
Sockets in .NET - .NET
Learn how the Socket class functions as a cross-platform abstraction of socket networking communication in .NET.docs.microsoft.comSockets in .NET - .NET
Learn how the Socket class functions as a cross-platform abstraction of socket networking communication in .NET.docs.microsoft.com
The links above are for the low level Sockets APIs. Although they will get you down into the weeds with details, they also teach some important concepts, specially if you follow the synchronous code examples. From there you should just look at the code examples from the aforemention TcpClient and TcpListener classes.