How to get IP address from sockaddr

前端 未结 6 1568
慢半拍i
慢半拍i 2020-12-28 14:25

I want to try and get the ip address of a client after calling accept. This is what I have so far, but I just end up getting some long number that is clearly not an ip addr

6条回答
  •  借酒劲吻你
    2020-12-28 15:25

    That long number is the IP address, in integer form (an IP address is just an integer, after all; it's just easier for people to use when we split the octets apart and put it into dot notation).

    You can use inet_ntoa to convert the integer value to standard dot notation.

提交回复
热议问题