How can I find the IP that's binded to a socket? When doing this:
It gives me "0.0.0.0:<port>", where <port> is the binded port. So I can get the port number, but now I also need the IP address...Code:struct sockaddr_in local; local.sin_family = AF_INET; local.sin_port = htons(0); local.sin_addr.s_addr = INADDR_ANY; memset(&local.sin_zero,0,8); // Bind stuff int saSize = sizeof(struct sockaddr); getsockname(sock,(struct sockaddr *)&local,&saSize); printf("%s:%d\n",inet_ntoa(local.sin_addr),ntohs(local.sin_port));



LinkBack URL
About LinkBacks



