I am writing a client server program that server receive message from client. I want to see the client's IP address on the server side. How can I do this? I would be grateful if you could help me. Thanks
Since you are using QTcpSocket
, I think .peerAddress
is what you are looking for.
class Server : public QTcpServer {...}
On accept
void Server::acceptConnection() {
std::cout << "new connection!\n";
client = nextPendingConnection();
std::cout << client->peerAddress().toString();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With