Read Data From Ethernet port using C

S

Thread Starter

Santosh

Sir,

Actually I am capable of transmitting data from my PLC side to a PC through an ethernet cable. But i don't know how to gather those data using C program.

So anyone please help me ....

Thanks
 
Look up on your favorite search engine how to program with TCP/IP sockets. If you are programming on windows you may want to consider C# or C++ with visual studio.

Basically the idea is to open a port connection as client on one end and server on the other (it doesn't matter which is which, just check to see which connection types your PLC supports first). The server waits and listens on a port for the client. Once the client connects you have a valid socket and you can send data in and read it out just like a file or serial port. Some OS'es support non blocking reads which is nice if you are in a polling loop and need to do other things. If you don't have this your call to read the port wont return until there is data.

KEJR
 
Top