Jump to content

Ethernet comms question

Recommended Posts

  • MVP 2023

Many years ago (many, many) when I was young and stupid (okay, slightly less stupid), I had some confusion about PLC Ethernet comms (didn't we all?). I had the need recently to have another look at a program I had written back then. This program, running on a V1210, exchanges data with several V570s simultaneously using MODBUS TCP. Each connection uses a separate socket, but all 4 sockets were initialized with the same port number, 20257. This program is still in the field and running flawlessly. My question is, why? How is it possible for the communication to work properly when all the sockets have the same port number? How does it all get sorted out properly so that the data ends up in the correct place?

Link to comment
Share on other sites

  • MVP 2023

maybe this link is helpful



P. S. I like this comment from link


Socket has a port on either side. The server port is the one the client addressed its initial packet to, but that packet was sent from a temporary port on the client. That combination of IP and port is a clear return address for the server to separate the traffic for multiple sockets

It's just the same way you can have text conversations with your mum, your wife, your daughter and your mistress and make sure you don't say the wrong thing to the wrong person.

Link to comment
Share on other sites

Yo Flex,

The port is really just identifying what service to use. It's kinda a logical construct. It's not like the IP address that has to be unique like a phone number. The port could be looked at like the number to a building, but ever office in the building has it's own unique phone number or IP if you will.  Like the most common port on the internet is port 80 which is most non-secure socket connections for web pages. The server is listening to port 80 just waiting for an IP to come request something so it can send something back.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.