Get the IP address of the remote host QTcpServer

I am using Qt to create a TCP server using QTcpServer. Every time a client connects to the server, I would like to know the IP address and port number of the remote host. I tried searching for documentation, but could not find information on this topic.

I know there has to be a way, I just can't figure it out. Help me please.

+4
source share
1 answer

QTcpServer will not tell you the address / port directly on the incoming connection, but you can get it by getting the connected QTcpSocket from QTcpServer :: nextPendingConnection (), and then using the peerAddress () and peerPort () methods of QTcpSocket.

+7
source

Source: https://habr.com/ru/post/1395528/


All Articles