ANP- 9. Socket Programming in UNIX (structures and functions)
ANP- 9. Socket Programming in UNIX (structures and functions)
Topics
• Socket address structures
Socket Programming in UNIX • Byte ordering functions (conversion between
(Basic Structures and auxiliary host and network order)
functions) • Byte manipulation functions
Harshad B. Prajapati • Address conversion functions
Associate Professor
Information Technology Department,
Dharmsinh Desai University, Nadiad
1
7/21/2017
2
7/21/2017
Conversion to host byte order. l for long (4 bytes) and s for short (2 bytes) Returns: 0 if equal, nonzero if unequal
uint16_t ntohs(uint16_t net16bitvalue ) ;
uint32_t ntohl (uint32_t net32bitvalue ) ;
3
7/21/2017
#include <sys/stat.h>
int isfdtype(int sockfd, int fdtype);
Returns: 1 if sockfd is of specified fdtype, 0 if not, -1 on error.