Keeping Track of connected TClientSocket

My application runs a Server Exe (TServerSocket) on one machine and Client Exes (TClientSocket) on other machines.

TClientSocket.Socket.SendText refers to just the Server machine so messages go to Server.

Problem is when I need to send message to specific Client via ServerSocket.Socket.Connections[n]

My logic was to check for ServerSocket.Socket.Connections[n].RemoteAddress and send accordingly. Now few machines ServerSocket.Socket.Connections[n].RemoteAddress is that of the Centralised Firewall therefore I cannot trace the correct Client.

Please Advice.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
port forwarding is not set
i'm guessing this is over vpn or internet ?

looks like you need 2-way communication
client server is technically the client initiating a request and the server giving a response.

> same as webserver
Sinisa VukSoftware architectCommented:
Try iterate as...
for i:=1 to Srv.ClientCount do
  Srv.Client[i-1] ....

Open in new window

Use this instead of remoteaddress:
Srv.Client[i-1]).PeerAddr ... //client ip address
Srv.Client[i-1]).PeerAddr ... //client tcp port

Open in new window

Allan_FernandesAuthor Commented:
Dear Sinisav,
    I am using Delphi 2007 and am planning to move to Xe2 shortly.
    Neither has  'TServerSocket.Client'  property ?

Dear Geert_Gruwez,
    This is over MPLS network.

    Messages are going across both ways when I loop with
         For i := 0 to ServerSocket.Socket.ActiveConnections-1
   Problem is when I need to send to specific Client .
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Geert GOracle dbaCommented:
i'd contact the network admin
there is obviously a difference amongst your connected clients

i don't think anything you do with Delphi will provide a solution
Sinisa VukSoftware architectCommented:
For my part of comment:
I'm provide code which I use with great ICS (tcp components). give a try to build simple client - server (there are samples in demo folder) with ICS.
Allan_FernandesAuthor Commented:
I am in touch with the network admin and I had earlier asked him to open the relevant ports on the FireWall, that did not help. What can I ask him to do now ? Is there any tracing method that can show that the issue is not with the application.

I use ICS components for FTP and Emails. Whereas my application is large and have been coded around the Basic Sockets components. Even my file transfers happen over raw sockets.

In fact I am trying out what is this OnGetSocket , TServerClientWinSocket. Cannot get any example. Any Clues?
Allan_FernandesAuthor Commented:
I have found a solution, please advice if it will work in all circumstances.

I am using the SocketHandle to keep a unique ID for each connection. Whenever the client connects he submits his IP to the server. This I check during the OnServerRead Socket.RemoteAddress and if it does not match I store the Clients correct IP and SocketHandle in stringlists which I later use while parsing through the Servers Active Connections.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Allan_FernandesAuthor Commented:
It worked for me
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.