gtpc1m3zTransmission Control Protocol/Internet Protocol

inet_addr -- Construct Internet Address from Character String

The inet_addr function interprets character strings representing numbers expressed in standard dotted decimal notation and returns numbers suitable for use as an internet address.

Format

#include  <types.h>
#include  <socket.h>
u_long    inet_addr(char *cp);

cp
A character string in standard dotted decimal notation.

Normal Return

The internet address is returned in network byte order.

Error Return

A return code equal to -1 indicates a character string that is not valid.

Programming Considerations

Examples

The following example converts character IP address to network byte order.

#include <types.h>
#include <socket.h>

·
·
·
struct sockaddr_in server_addr;
·
·
·
servername.sin_addr.s_addr = inet_addr("129.5.24.1");

Related Information

None.