Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTcpServer mixing clients
#5
(12-18-2018, 06:21 PM)henschen Wrote: Clients are identified with MAC address.

How is your server obtaining each client's MAC? That is not something it can query from the connected TCP sockets. Are the clients sending their own MACs to the server after connecting to it? How does each client obtain the MAC it is using to connect with (a PC/device may have multiple network interfaces, and thus multiple MACs). Have you verified that on the server side, you are not accidentally tracking multiple clients with the same MAC? Since a MAC and IP are closely related, multiple clients connecting from the same PC/device would have not only the same IP, but also the same MAC, too.

(12-18-2018, 06:21 PM)henschen Wrote: Every client has its own log file.

How are you determining the log filename for each client? Are you sure multiple clients are not simply logging to the same file?

(12-18-2018, 06:21 PM)henschen Wrote: 1. Socket handle never changes.

Not for an individual client, no. Its socket handle is consistent for the lifetime of its connection. But multiple clients connected concurrently have unique socket handles. And like I said earlier, once a given client disconnects and its socket handle is closed, the OS is free to reuse that same handle for a new client socket afterwards.

(12-18-2018, 06:21 PM)henschen Wrote: 3. Third line sends message occasionally to wrong client.

Based on what you have described, the only way I can see can happening is if you are manually dipping into the TIdTCPServer.Contexts list to choose a target TIdContext to send to, and are choosing the wrong client at times. What does that code actually look like? What is your criteria for choosing the target client? I'm assuming that since you are tracking client MACs, one client (or the server itself) can opt to send a message to a specific client's MAC, is that right?

Within the server's OnConnect/OnExecute/OnDisconnect events, the provided TIdContext parameter is unique to each client. If you send the message to the same TIdContext that fires the event, there is no possibility for cross-over with another client.

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: 1 Guest(s)