Something like peer-to-peer

Hey all !

I have a nice question ( maybe simple one ).
I coded a simple server , chat server. I want to implement send files options. But here I come to a nasty thing .. I cannot face out.

Let's say that two clients are already connected to the server.( clients are just from another contry each other , and the server , wherever in the world ).

Let's say I want to send a file from client 1 to client 2.Cool , what can I do , I can send the file to the network socket descriptor of client 1 -> to be sent to the server -> and then the server to receive it from its socket descriptor and sent to client 2. What a loose of speed , isen't it ?

I want to implement , something like peer-to-peer ( if its the corect idea to be mentioned ). I want something like :

Client 1 -> client 2. not : Client 1 -> Server -> Client 2 ( normaly some headers wil be passed to the server to client , to be known by client 1 where to send those data ).

What I really mean : Ehen client1 wants to send data to client 2 , those data to be send directly ( * ) to client 2.

(*) : client 1 says to server : Hey I wanna send a file to client 2 , give me its address to send to it that file ( peer to peer ).

Something like .. maybe I haven't explain really what I want , but .. if someone can give me a clue !

Thanks in advance ! :wink: