Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <inet.h>
Link against: libc.lib

ntohl

Interface status: externallyDefinedApi

ntohl htonl

Description

These are also declared as functions.

[Top]


ntohs

Interface status: externallyDefinedApi

ntohs htons

Description

These are also declared as functions.

[Top]


Typedef uint16_t

Interface status: externallyDefinedApi

typedef __uint16_t uint16_t;

Description

denotes a unsigned integer type with a width of exactly 16 bits.

[Top]


Typedef uint32_t

Interface status: externallyDefinedApi

typedef __uint32_t uint32_t;

Description

Unsigned long int

[Top]


Typedef in_addr_t

Interface status: externallyDefinedApi

typedef __uint32_t in_addr_t;

Description

Internet address manipulation

[Top]


Typedef in_port_t

Interface status: externallyDefinedApi

typedef __uint16_t in_port_t;

Description

Internet port manipulation

[Top]


Typedef size_t

Interface status: externallyDefinedApi

typedef __size_t size_t;

Description

Used for sizes of objects.

[Top]


Typedef socklen_t

Interface status: externallyDefinedApi

typedef __socklen_t socklen_t;

Description

Socket address length type.

[Top]


htonl(uint32_t)

Interface status: externallyDefinedApi

IMPORT_C uint32_t htonl(uint32_t);

Description

These routines convert 16 and 32 bit quantities between network byte order and host byte order. On machines which have a byte order which is the same as the network order, routines are defined as null macros.

These routines are most often used in conjunction with Internet addresses and ports as returned by gethostbyname and getservent .

Bugs:

On the VAX bytes are handled backwards from most everyone else in the world.

Parameters

uint32_tuint32_t

Note: This description also covers the following functions - htons(uint16_t)htons(uint16_t) ntohl ntohs

Return value

uint32_tuint32_t

See also:

[Top]


htons(uint16_t)

Interface status: externallyDefinedApi

IMPORT_C uint16_t htons(uint16_t);

Description

Parameters

uint16_tuint16_t

Refer to htonl(uint32_t)htonl(uint32_t) for the documentation

Return value

uint16_tuint16_t

See also:

[Top]


inet_addr(const char *)

Interface status: externallyDefinedApi

IMPORT_C in_addr_t inet_addr(const char *);

Description

  struct in_addr or some other internal binary representation, in network byte order).
 It returns 1 if the address was valid for the specified address family, or
 0 if the address was not parseable in the specified address family, or -1
 if some system error occurred.
 This function is presently valid for AF_INET and AF_INET6.
  struct in_addr or some other binary form, in network byte order) to presentation format
 (suitable for external display purposes).
 The size argument specifies the size, in bytes, of the buffer *dst It returns NULL if a system error occurs (in which case, errno will have been set), or it returns a pointer to the destination string.
 This function is presently valid for AF_INET and AF_INET6.
  The routines inet_addr and inet_aton interpret character strings representing
numbers expressed in the Internet standard ‘.’ notation.

The inet_pton function converts a presentation format address (that is, printable form as held in a character string) to network format (usually a struct in_addrin_addr or some other internal binary representation, in network byte order). It returns 1 if the address was valid for the specified address family, or 0 if the address was not parseable in the specified address family, or -1 if some system error occurred. This function is presently valid for AF_INET and AF_INET6.

The inet_aton routine interprets the specified character string as an Internet address, placing the address into the structure provided. It returns 1 if the string was successfully interpreted, or 0 if the string is invalid. The inet_addr functions return numbers suitable for use as Internet addresses.

The function inet_ntop converts an address *src from network format (usually a struct in_addrin_addr or some other binary form, in network byte order) to presentation format (suitable for external display purposes). The size argument specifies the size, in bytes, of the buffer *dst It returns NULL if a system error occurs (in which case, errno will have been set), or it returns a pointer to the destination string. This function is presently valid for AF_INET and AF_INET6.

The routine inet_ntoa takes an Internet address and returns an ASCII string representing the address in ' . ' notation.

All Internet addresses are returned in network order (bytes ordered from left to right). All network numbers and local address parts are returned as machine byte order integer values.

Diagnostics:

The constant INADDR_NONE is returned by inet_addr for malformed requests.

Examples:

#include <stdio.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#define IPV6ADDRSIZE 48
int main()
    {
     unsigned int nbo_value;
     char *ipaddrstring="1.2.3.4";
     char *ipaddrholdr=NULL;
     char *ipv6addrstring="8000::123:4567:89AB:CDEF";
     struct in_addr ipstruct;
     struct in6_addr ipv6struct;
     char result[IPV6ADDRSIZE];
     int err;
     int size;
     const char* error;
     nbo_value=inet_addr(ipaddrstring);
     if(nbo_value == -1)
      {
       printf("inet_addr failed0);
      }
     else
      {
       printf("inet_addr passed0);
      }
     ipstruct.s_addr=nbo_value;
     ipaddrholdr=inet_ntoa(ipstruct);
     if(ipaddrholdr==NULL)
      {
       printf("inet_ntoa failed0);
      }
     else
      {
      printf("ipaddr is %s0,ipaddrholdr);
      }
     err=inet_pton(AF_INET6,ipv6addrstring ,&ipv6struct;);
     if(err ==0  || err==-1)
     printf("inet_pton Failed0);
     else
     printf("inet_pton passed0);
     size=sizeof(result);
     error=inet_ntop(AF_INET6,&ipv6struct.s6;_addr,result,size);     
     if(error==NULL)
      {
      printf("inet_ntop failed");
      }
     else
      {
      printf("inet_ntop passed");
      }
     err=inet_aton(ipaddrstring,&ipstruct;);
     if(err==0)
     {
      printf("invalid address ");
     }
     else
      {
      printf("inet_aton passed ");
      }
    
     return 0;
}
Output:
inet_addr passed
ipaddr is 1.2.3.4
inet_pton passed
inet_ntop passed
inet_aton passed

The inet_ntop and inet_pton functions conform to -xns5.2. Note that inet_pton does not accept 1-, 2-, or 3-part dotted addresses; all four parts must be specified and are interpreted only as decimal values. This is a narrower input set than that accepted by inet_aton. These functions appeared in BSD 4.2.

Bugs:

The value INADDR_NONE (0xffffffff) is a valid broadcast address, but inet_addr cannot return that value without indicating failure. The newer inet_aton function does not share this problem. The problem of host byte ordering versus network byte ordering is confusing. The string returned by inet_ntoa resides in a static memory area. Inet_addr should return a struct in_addrin_addr.

Parameters

const char *

Note: This description also covers the following functions - inet_aton inet_ntoa inet_ntop inet_pton

Return value

in_addr_tin_addr_t

See also:

[Top]


inet_ntoa(struct)

Interface status: externallyDefinedApi

IMPORT_C char* inet_ntoa(struct in_addr);

Description

Parameters

struct in_addr

Refer to inet_addr for the documentation

Return value

char *

See also:

[Top]


inet_ntop(int,const void *,char *,socklen_t)

Interface status: externallyDefinedApi

IMPORT_C const char* inet_ntop(int, const void *, char *, socklen_t);

Description

Parameters

int

const void *

char *

socklen_tsocklen_t

Refer to inet_addr for the documentation

Return value

const char *

See also:

[Top]


inet_pton(int,const char *,void *)

Interface status: externallyDefinedApi

IMPORT_C int inet_pton(int, const char *, void *);

Description

Parameters

int

const char *

void *

Refer to inet_addr for the documentation

Return value

int

See also:

[Top]


inet_aton(const char *,struct in_addr *)

Interface status: externallyDefinedApi

IMPORT_C int inet_aton(const char *, struct in_addr *);

Description

Parameters

const char *

struct in_addrin_addr *

Refer to inet_addr for the documentation

Return value

int

See also: