100% found this document useful (1 vote)
55 views2 pages

Socket Headers

The document discusses several C header files that define types, constants, and structures used for network programming on Unix-like systems. It summarizes the purpose and key contents of header files for sockets, internet addresses, error handling, and the network database. These include definitions for address families, socket types, internet addresses, port numbers, error codes, and structures for ARP requests and the system name.

Uploaded by

meenakshigm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
55 views2 pages

Socket Headers

The document discusses several C header files that define types, constants, and structures used for network programming on Unix-like systems. It summarizes the purpose and key contents of header files for sockets, internet addresses, error handling, and the network database. These include definitions for address families, socket types, internet addresses, port numbers, error codes, and structures for ARP requests and the system name.

Uploaded by

meenakshigm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 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


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 reference


struct 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-dependent
communications network
char release[] current release level of this implementation
char version[] current version level of this release
char machine[] name of the hardware type on which the system is running

You might also like