Yes, it is stored in the socketaddr_in structure, you can extract it using:
SOCKADDR_IN client_info = {0}; int addrsize = sizeof(client_info); // get it during the accept call SOCKET client_sock = accept(serv, (struct sockaddr*)&client_info, &addrsize); // or get it from the socket itself at any time getpeername(client_sock, &client_info, sizeof(client_info)); char *ip = inet_ntoa(client_info.sin_addr); printf("%s", ip);
source share