This patch does two things:
- Disallows creating more than one link from one socket to a multi socket input.
- Properly count links if there happen to be more than one link between the same sockets.
The new link counting should also be more efficient asymptotically.