Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Indy TWO Server COMMUNICATION



Permlink Replies: 3 - Last Post: Feb 26, 2017 3:59 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
faycal ben dhib

Posts: 2
Registered: 3/24/17
Indy TWO Server COMMUNICATION
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2017 2:09 PM
Hi,
i uses delphi 10.1 Berlin with indy.

My solution architect look like this :

Client send request to the central server : "CServer" , the centre server "Cserver" must connect to an other server "DBServer" ( database connector ) and submit the query. the "DBServer" execute the query vs the database and return the result to the "Cserver" that will send the result to the Client.

How the server Cserver can connect to DBServer AND ACTS AS A CLIENT? and with witch component ? Idserver or an Idclient ???

Best reagrds.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Indy TWO Server COMMUNICATION
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2017 6:35 PM   in response to: faycal ben dhib in response to: faycal ben dhib
faycal wrote:

How the server Cserver can connect to DBServer AND ACTS AS A CLIENT?

You just answered your own question - use a client socket for that second
connection.

--
Remy Lebeau (TeamB)
faycal ben dhib

Posts: 2
Registered: 3/24/17
Re: Indy TWO Server COMMUNICATION
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 25, 2017 1:16 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi,
creating TidTcpClient for eache client connexion in the server Onexecute event is it thread-safe ?
My protocol looks like : all client must go throw the server beacause the security and client may need some thing else then query like file, screen save, audio save etc ..

Client : (i need query) -------------------->Cserver
Cserver (execute this query)---------------------DBServer
DBserver(return result) ---------------------Cserver
Cserver(return data) ------------------------Client

Please any code implementation exemple for this request .

best regards.

Remy Lebeau (TeamB) wrote:
faycal wrote:

How the server Cserver can connect to DBServer AND ACTS AS A CLIENT?

You just answered your own question - use a client socket for that second
connection.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Indy TWO Server COMMUNICATION
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2017 3:59 PM   in response to: faycal ben dhib in response to: faycal ben dhib
faycal wrote:

creating TidTcpClient for eache client connexion in the
server Onexecute event is it thread-safe ?

Yes, if you create and destroy it within the same thread context that is
managing the calling server connection. In other words, limit usage of a
given TIdTCPClient to the OnConnect, OnDisconnect, and OnExecute events of
a single server connection. You can repeat that for multiple connections,
since each server connection runs in its own thread. For instance, proxy
components like TIdMappedPortTCP, TIdHTTPProxyServer, TIdSocksServer, etc
do exactly this when their clients request outgoing connections to secondary
servers.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02