Direct data transfer between two connections in Indy (TIdContext)

start the TIdTCPServer server and the client using a web browser (or any other software) for communication, I don’t know the protocol, but what I'm trying to do is send data between the client and the other connection (both are connected to the same TIdTCPServer ), for example, the data sent by the first client is transmitted to the second client, and the data sent by the second client is transmitted to the first client as a proxy (I can not use the proxy server, since this is only this condition), and TIdTCPServer should still receive other customers and processing It is the data.

I came across the first line of code, since TIdContext.Connection.Socket.ReadLn requires a delimiter, and the client protocol is unknown to the server.

any ideas?

thank.

+3
source share
1 answer

You can look at the source code TIdMappedPortTCPand TIdHTTPProxyServerto find out how they transmit arbitrary data between connections in both directions. Both components are used TIdSocketList.SelectReadList()to detect when either connection has read data. TIdMappedPortTCPthen uses TIdBuffer.ExtractToBytes()and TIdIOHandler.Write(TIdBytes), while TIdHTTPProxyServeruses TIdTCPStreamand instead TIdBuffer.ExtractToStream().

+3
source

Source: https://habr.com/ru/post/1796487/


All Articles