#include <netinet/in.h>
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
hton
: 호스트 바이트 오더(컴퓨터 고유의 바이트 순서)를 네트워크 바이트 오더로 변환
ntoh
: 반대s
는 unsigned short
, l
은 unsigned int
바이트 순서: 보통 PC에서 사용하는 것이 리틀 엔디언, 인터넷 표준 네트워크에서는 빅 엔디언 사용 (엔디언)
byte order 변환 API (host ↔ network byte order)
in_addr_t
#include <netinet/in.h>
in_addr_t inet_addr(const char *cp);
0.0.0.0
형식의 IPv4 주소를 네트워크 바이트 오더의 바이너리 주소로 변환 (unsigned int
)inet_addr(3) - IP주소를 network byte order의 binary 주소로...
/* According to POSIX.1-2001 */
#include <sys/select.h>
/* According to earlier standards */
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
struct timeval *timeout);