The ip string can be converted to the in_addr structure with the InetPton function. It is used like this: InetPton(AF_INET, strIP, &ipv4addr) You need to include the "Ws2tcpip.h" header file, use the library "Ws2_32.lib" and DLL "Ws2_32.dll".

The sin_addr is a union (s_addr is a unsigdned long (4 bytes) data type). // INADDR_ANY means to listen on all interfaces. // inet_addr (Internet address) is used to convert a string (char *) into unsigned int. Program examples on how to use the InetNtop()/inet_ntop The function inet_addr() converts a dotted IPv4 address to a 32-bit unsigned long integer quantity. The inet_addr() function is defined as: unsigned long inet_addr(const char FAR *cp); The cp field is a null-terminated character string that accepts an IP address in dotted notation. Note that this function returns an IPv4 address as a 32-bit inet_addr(3) [linux man page] - Unix

If I use ifconfig, the output says my bcast is 10.0.2.255 and inet addr is 10.0.2.15. A related query on this subject pertains to the selected answer to this question , wherein the use of /24 (24 bit IP) in the actual IP address confuses me.

Unlike inet_aton(3) and inet_addr(3), inet_pton() supports IPv6 addresses. On the other hand, inet_pton () only accepts IPv4 addresses in dotted-decimal notation, whereas inet_aton (3) and inet_addr (3) allow the more general numbers-and-dots notation (hexadecimal and octal number formats, and formats that don't require all four bytes to be 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS. partner.sin_addr.s_addr = inet_addr(ip.c_str()); I attempted to use the functions mentioned but they were undefined. I attempted to define the macro in many different spots but nothing happened. Another thread said that I should include Ws2tcpip.h

The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned.

What is Inet address? - ALLInterview Inet address is a class encapsulating both this ip address and the domain name for this address.This class can be used for getting the ip address of systems by providing the name and vice versa.This is done by some functions in the class such as getaddress(),getbyname() inet_aton() -- convert Internet dot address to network address