06 — PORTS & SOCKETS

How one IP handles many conversations.

Estimated 8 minutes.

One device, many programs.

A single PLC can talk Modbus, host a web page, accept SSH, and serve OPC UA — all at the same time. They all share one IP address. So how does the device know which incoming packet belongs to which program?

Ports.

Each program listens on a specific port number. The IP is the building. The port is the apartment number. Together they tell the network exactly where to deliver.

One IP, many ports.

Same address. Different doors.

How many ports?

Port numbers run 0 to 65,535. That's plenty. Most are free for any program to use, but some are reserved by convention for well-known services.

Industrial well-known ports.

Memorize these — you'll see them every day.

Match protocol to port.

Pick the right port number for each industrial protocol.

A socket = IP + port.

When a client connects to 192.168.1.10:502, the combination IP+port is called a socket. It uniquely identifies one conversation. Two simultaneous conversations to the same server use different client-side ports.

Be the port concierge.

Packets arrive at the device with port numbers. Send each one to the room that serves it. Wrong room = connection refused.

Why won't Modbus connect?

You can ping a PLC at 192.168.1.10, but your Modbus client times out. Most likely cause?

  • IP is wrong
  • Port 502 is blocked by a firewall
  • Cable is bad

Firewalls work on ports.

A firewall's job is to allow some ports and block others. On a plant network, you might allow port 502 (Modbus) between PLCs and SCADA, but block port 23 (Telnet) from the corporate network. This is how you keep production isolated.

Two clients, one server.

Two HMIs simultaneously read from one PLC on port 502. Does that work?

  • No — only one client per port
  • Yes — server port is shared, client ports differ
  • Only if the PLC is configured for it

You can troubleshoot at the port level.

  • IP delivers to the device. Port delivers to the program.
  • Port 502 = Modbus TCP. 102 = S7. 4840 = OPC UA. 44818 = EtherNet/IP.
  • A socket = IP + port — one conversation.
  • Ping working but protocol failing = port problem, often a firewall.

Lesson 06 complete.

  • You know what a port is and why it exists.
  • You can name the major industrial ports.
  • You can diagnose port-level connectivity issues.