Probably because your switch has seen client B's MAC address on the port
to client A and has remembered that. It will therefore send the reply on
the ethernet port to client A, not to client B's erhernet port.
This seems to be a networking issue, not a programming issue. Therefore
this question might be more appropriate on a different forum.