Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTcpServer mixing clients
#3
(12-17-2018, 04:21 PM)henschen Wrote: We are running TIdTcpServer on a cloud server. Usually all clients connect from the same local network. So their remote IP addresses seems to be the same at the server side.

If the clients have to pass through a proxy/router to reach your server, then yes, the server would see the same IP for all of them, but different ports.

(12-17-2018, 04:21 PM)henschen Wrote: Sometimes sending message from server change clients. So message sent to client A has gone to client B. It happens maybe once per about 1000 messages but still too often. Usually it happens when there is very short interval between client messages. Still socket handle, remote port and other client specific information remains correct.

How are you determining which client to send a given message to? The client's IP address alone is not unique enough for identification purposes. At the very least, you would need to use the client's IP and port. Though, that pair can be reused when a client disconnects and a new client connects. Same with a socket handle. Such things are only unique for the lifetime of a connection, and can then be reused once the connection is gone.

You may need to require your clients to explicitly login to the server using a unique identifier, such as a username. Maybe also send the client's local LAN IP as well. You can manually keep track of such values inside of the TIdContext object of each connection, either by:

- using the TIdContext.Data property

- deriving a new class from TIdServerContext to add whatever properties you want, then assign that class to the TIdTCPServer.ContextClass property, and then type-cast TIdContext object pointers when needed.

Reply


Messages In This Thread
TIdTcpServer mixing clients - by henschen - 12-17-2018, 04:21 PM
RE: TIdTcpServer mixing clients - by kudzu - 12-17-2018, 06:19 PM
RE: TIdTcpServer mixing clients - by rlebeau - 12-17-2018, 08:43 PM
RE: TIdTcpServer mixing clients - by henschen - 12-18-2018, 06:21 PM
RE: TIdTcpServer mixing clients - by rlebeau - 12-18-2018, 09:04 PM
RE: TIdTcpServer mixing clients - by henschen - 12-19-2018, 01:26 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)