inicio mail me! sindicaci;ón

welcome to my space

determining IP address when using INADDR_ANY

  • I'm writing a server in Perl, and I use INADDR_ANY to accept the connection on any one of several IP addresses. Is there any way to determine which IP address the connection was made on? I know I could run multiple instances of the server on each of the IP addresses, but I'd rather run one instance, and have different output depending on which IP address was contacted. Along similar lines, I would like to be able to determine all the IP addresses that I was listening on when using INADDR_ANY. I'd need to know how to do this in perl.


  • Try using the getsockname() function, like this: $mysockaddr = getsockname(SOCK); ($port, $myaddr) = sockaddr_in($mysockaddr); printf "Connect to %s [%s]n", scalar gethostbyaddr($myaddr, AF_INET), inet_ntoa($myaddr); Vladimir


  • Just to be sure this is understood, I want my IP address that the connection is made on, not the remote IP address.


  • I think that's what I was looking for. Thank you so much.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about determining IP address when using INADDR_ANY , Please add it free.