As the title says, can client A connect to client B on different machines, when the server is on the same machine with client B ?
Note that the client B and server on the machine have different port numbers.
And client B acts like a server i.e. it also listen for clients, but client A must first handshake with the server and then with client B. Is this possible? Thank you.
The criteria that determine uniqueness (for connectivity) are:

IP Address
Protocol
Port

Thus, if A and B have different IP addresses, they all use TCP, but B's server has a different port than B's client, then, all other things being equal, they should all be reachable.
can peer A connect to peer B if server is on peer B?