Search code examples
c++delphip2p

I am trying to make p2p network over tcp


I am using Indy components pack for it. Actually I am succeed to make p2p network over udp and it's still working now, but with udp I need to send some ping package every time, otherway the router will remove the virtual port in mapping port list! For video or sound or gaming project over udp is the best way but for my project I need it over tcp.

How I did: I have 1 server machine owned a real ip, all clients before swiching to p2p mode need to send package to the server, and now server know the all clients virtual port (out port) maked on the router, if some client want to send data to another client, he just need to send data to another client ip and virtual port on router. Router can map it automatically.

I was try same way in tcp , the client was send data to another client ip and virtual port (on router) but tcp client component can't receive it! With udp it can receive

Why over tcp p2p topology different then udp

Or how can I send data to server machine using with idtcpserver component for create a virtual port on the router


Solution

  • You bind sockets with TCP. UDP are not bound the same way.
    Difference between TCP and UDP

    In the package that you have (if you provide the name of it you might get more help) there should be some sort of connection / socket / binding to the client that is connecting to your server. It is that connection that you need to send data to.