How to differentiate between multiple different connections connecting to a common socket?
Connect each of the male connections to an output GPIO pin.  Connect each female to an input GPIO pin.

In a loop, cycle through each of the outputs, turning one on (high) at a time.  While each output is high, check all the inputs to see which, if any, is high.

If you don't have enough GPIO pins (13 total), there are various options.  The easiest is to use a multiplexer on the input pins (reduces 9 inputs to 1 input and 4 outputs).  You can also use a one-hot decoder on the output pins (reduces 4 outputs to 2 outputs).  As a last resort, you can consider an IO expander chip (replaces all 13 pins with a serial bus, such as I2C or SPI).