If I'm understanding you right you want
localhost on machines A and B to point to the same place -- This is simultaneously exactly what's happening and completely impossible :-)
localhost by convention always points to
127.0.0.1, the magic loopback IP of the local machine (i.e. 127.0.0.1 on machine A always means machine A; 127.0.0.1 on machine B always means machine B). It's not an address that can be shared between multiple machines (in fact the entire
127.0.0.0/8 network is reserved for loopback use).
To do what you want you need to connect both machines over a network, assign them non-loopback IPs (private addresses out of
192.168.0.0/16) & run your service over those addresses.
Consult a good networking book for more details...