Please do not use sockets directly, those are for communicating with the outside world.

MAME uses "slot devices" for things that allow you to connect multiple things to a port. I would advise looking at the contents of src/devices/bus/rs232/ for inspiration.