3

ive a sever running TIdTCPServer, and Client Using Web Browser (or any other software) to Communicate, i dunno the protocol, but what im trying to do is to Send The Data between the client and another Connection (Both 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, like a proxy (i cant really use a proxy server since its just this one condition) and the TIdTCPServer should still be receiving other clients and processing their data.

i stumbled upon the first line of code, since TIdContext.Connection.Socket.ReadLn requires a Delimiter, and the Client's Protocol is unknown to the server.

any ideas?

thanks.

Vibeeshan Mahadeva
  • 7,147
  • 8
  • 52
  • 102
killercode
  • 1,666
  • 5
  • 29
  • 42
  • 1
    Maybe the TIdMappedPortTCP component in Indy is helpful, with some modification - see http://stackoverflow.com/questions/4136226/proxy-server-using-indy – mjn Mar 05 '11 at 17:33
  • 1
    When faced with this same issue I used [ICS - The Internet Component Suite](http://www.overbyte.be/frame_index.html?redirTo=/products/ics.html) components: Unlike Indy they're not blocking so you can easily receive AND send at the same time. – Cosmin Prund Mar 05 '11 at 18:28
  • i cant use TIedMppedPortTCP since its actually a server, with lots of functions, providing information and stuff, and that just a feature inside the server, to take the client to another client, and i cant move to ICS since im doing cross-platform development :( – killercode Mar 06 '11 at 14:46

1 Answers1

3

You can look at the source code for TIdMappedPortTCP and TIdHTTPProxyServer to see how they pass arbitrary data between connections in both directions. Both components use TIdSocketList.SelectReadList() to detect when either connection has data to read. TIdMappedPortTCP then uses TIdBuffer.ExtractToBytes() and TIdIOHandler.Write(TIdBytes), whereas TIdHTTPProxyServer uses TIdTCPStream and TIdBuffer.ExtractToStream() instead.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • thats very very complicated since i never really looked at Indy Source before, and even if i did so, i dont think ill be able to make my new code cross-platform. – killercode Mar 08 '11 at 06:29
  • Indy is a cross-platform library. What I described works on all platforms. There are many different ways to transfer data between multiple `TIdContext` objects, depending on what you actually need to transfer. – Remy Lebeau Mar 08 '11 at 08:04