Suppose that host A wants to talk to host B on a network. All messages from A go to server X first and X forwards the message to B. NOW, using simple XOR encryption, A can make the message unreadable to X (and also B), but how can A tell B which key to use for decifering without revealing the key to X? A and B can only communicate through X.

Code:
[A] ---> [X] ===> [B]
[A] <=== [X] <--- [B]

---> Sent message
===> Forwarded message
I have been wondering about this for some time and can't seem to find a solution.

I know, it can be done using the RSA encryption algorithm, but I am interested in using XOR encryption (or similar reversible algorithm).