- Socket Descriptors123#include <sys/socket.h>int socket(int domain, int type, int protocol);Returns: file (socket) descriptor if OK, −1 on error
123#include <sys/socket.h>int shutdown(int sockfd, int how);Returns: 0 if OK, −1 on error
how : SHUT_RD SHUT_WR SHOT_RDWR
- Byte Ordering
123456789 #include <arpa/inet.h>uint32_t htonl(uint32_t hostint32);$ Returns: 32-bit integer in network byte orderuint16_t htons(uint16_t hostint16);$ Returns: 16-bit integer in network byte orderuint32_t ntohl(uint32_t netint32);$ Returns: 32-bit integer in host byte orderuint16_t ntohs(uint16_t netint16);$ Returns: 16-bit integer in host byte order
- translate btween binary and text1234567#include <arpa/inet.h>const char *inet_ntop(int domain, const void *restrict addr,char *restrict str, socklen_t size);Returns: pointer to address string on success, NULL on errorint inet_pton(int domain, const char *restrict str,void *restrict addr);Returns: 1 on success, 0 if the format is invalid, or −1 on error
dimain : AF_INET, AF_INET6
-