OS Unix [IBM aix]

AIX socket의 이해 1

infra 2021. 3. 1. 21:35

socket layer 구조

 

socket의 디렉터리 위치 : /usr/include/sys/socket.h 에 위치합니다.

 

vi 또는 cat으로 해당 파일을 읽어봅니다.

 

1.socket types 

1./usr/include/sys/socket.h의 socket types

가장 많이 사용되는 것

1. <* stream socket >  = TCP 소켓

2. <* datagram socket >  = UDP 소켓

3. <* raw-protocol interface >  = user가 transport를 직접 작성하는 native 소켓

 

소켓이 만들어질 때 결정되는 것이 socket types.

 

 

2.socket Option Flags

소켓 옵션은 프로그램 작성시에 정의 가능하며, OS의 parameter 형태로도 넣을 수 있음.

하지만, 프로그램 작성시 정의된 값이 우선 값으로 적용됨.

 

2./usr/lib/include/sys/socket.h의 socket option

 

3.socket functions

 

// Function declarations and prototypes.
*/

#ifndef _KERNEL
#ifdef  _NO_PROTO
int     accept();
int     bind();
int     connect();
int     getpeername();
int     getsockname();
int     getsockopt();
int     listen();
ssize_t recv();
ssize_t recvfrom();
ssize_t recvmsg();
ssize_t send();
ssize_t sendto();
ssize_t sendmsg();
int     setsockopt();
int     shutdown();
int     socket();
int     socketpair();
#else

socket function들은

kernel 내부에서 다양한 형태의 system call 및 function call, ioctl call 등으로

이루어짐 

 

4.socket FSM state definitions

 

/usr/include/netinet/tcp_fsm.h

모든 tcp socket은 현재의 상태를 갖고 있으며, tcp control block에 정보가 담겨있다.