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

https://stackoverflow.com/questions/11129212/tcp-can-two-different-sockets-share-a-port

 

P. S. I like this comment from link

https://www.quora.com/Can-multiple-sockets-use-the-same-port

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...