Sorry, links to Indy documentation are currently not working for me. I don't know if the sites are down or whatever but they're not loading in my browser at the moment.

I have a TIdCmdTcpServer in one "server" application, and a TIdCmdTcpClient in another "client" application. I know how to get the IP address of the Client once it has connected. What I don't know is how to distinguish between 2 clients that connect from the same ip address. Can anyone help?

有帮助吗?

解决方案

This isn't really an Indy question, more a general networking one.

Different clients at the same address must use distinct ports. And here I mean the port at the client end of the connection. So you distinguish between different clients at the same address by dint of them using different ports.

其他提示

DO NOT use TIdCmdTCPClient with TIdCmdTCPServer. They are not meant to be used together, and it is very easy to deadlock your communications with them, as they both use internal reading threads that expect the other peer to send data. Use TIdTCPClient with TIdCmdTCPServer or TIdCmdTCPClient with TIdTCPServer.

With that said, you could use the client's remote IP/Port to differentiate, but it is generally better to make your own identifier instead, such as requiring clients to log in with a username, that you can then track as needed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top