Socket Headers

2
1. The <sys/socket.h>- - Internet Protocol family This header file contains macro definitions related to the creation of sockets,with distinct integer values: SOCK_DGRAM -Datagram socket. SOCK_RAW - Raw Protocol Interface. SOCK_STREAM -Byte-stream socket. The <sys/socket.h> header shall define the following macros, with distinct integer values: AF_INET - Internet domain sockets for use with IP v4 addresses. AF_INET6 - Internet domain sockets for use with IPv6 addresses. AF_UNIX - UNIX domain sockets. 2. <sys/types.h> -defines data types For ex. It includes the following type definitions for unsigned int egers and addresses: typedef struct _quad { long val[2]; } quad; typedef long swblk_t; typedef unsigned long size_t; The following type definitions are for BSD compatibility only: Berkeley Software Distribution (BSD, sometimes called Berkeley Unix) typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; 3. netinet/in.h - Internet address family INADDR_ANY - IPv4 local host address. INADDR_BROADCAST - IPv4 broadcast address. The <netinet/in.h> header shall define the following types: in_port_t - Equivalent to the type uint16_t as defined in <inttypes.h> . in_addr_t - Equivalent to the type uint32_t as defined in <inttypes.h> . 4. #include <unistd.h>- standard symbolic constants and types

Transcript of Socket Headers

Page 1: Socket Headers

8/8/2019 Socket Headers

http://slidepdf.com/reader/full/socket-headers 1/2

1. The <sys/socket.h>- - Internet Protocol family

This header file contains macro definitions related to the creation of sockets,with distinct integer values:

SOCK_DGRAM -Datagram socket.SOCK_RAW - Raw Protocol Interface.

SOCK_STREAM -Byte-stream socket.

The <sys/socket.h> header shall define the following macros, with distinct integer values:

AF_INET - Internet domain sockets for use with IPv4 addresses.

AF_INET6 - Internet domain sockets for use with IPv6 addresses.

AF_UNIX - UNIX domain sockets.

2. <sys/types.h> -defines data types

For ex. It includes the following type definitions for unsigned integers and addresses:

typedef struct _quad { long val[2]; } quad;

typedef long swblk_t;

typedef unsigned long size_t;

The following type definitions are for BSD compatibility only: Berkeley Software

Distribution (BSD, sometimes called Berkeley Unix)

typedef unsigned char u_char;

typedef unsigned short u_short;

typedef unsigned int u_int;

typedef unsigned long u_long;

3. netinet/in.h - Internet address family

INADDR_ANY - IPv4 local host address.

INADDR_BROADCAST - IPv4 broadcast address.

The <netinet/in.h> header shall define the following types:

in_port_t - Equivalent to the type uint16_t as defined in <inttypes.h> .

in_addr_t - Equivalent to the type uint32_t as defined in <inttypes.h> .

4. #include <unistd.h>- standard symbolic constants and types

Page 2: Socket Headers

8/8/2019 Socket Headers

http://slidepdf.com/reader/full/socket-headers 2/2

5. <arpa/inet.h> - definitions for internet operations

For example , The following shall either be declared as functions, defined as macros, or both. If 

functions are declared, function prototypes shall be provided.

uint32_t htonl(uint32_t);uint16_t htons(uint16_t);

uint32_t ntohl(uint32_t);

uint16_t ntohs(uint16_t);

6. #include<sys/ioctl.h>

The ioctl socket function performs special operations on socket descriptor s.

7 . <errno.h>

This header file contains definitions for the macro identifiers that name system error status

conditions.

Ex. ENOBUFS - insufficient buffers in network software

8.<netdb.h>

This header file contains structures returned by the network database library. Internet addresses

and port numbers are stored in network byte order,

9. #include<net/if_arp.h> - arp protocol referencestruct arpreq {

struct sockaddr arp_pa;  /* protocol address */ 

struct sockaddr arp_ha;  /* hardware address */ 

int arp_flags;  /* flags */ 

};

9.<sys/utsname.h> - system name structure

The <sys/utsname.h> header defines structure utsname, which includes at least the following

members:

char sysname[] name of this implementation of the operating system

char nodename[] name of this node within an implementation-dependentcommunications network 

char release[] current release level of this implementationchar version[] current version level of this release

char machine[] name of the hardware type on which the system is running