Socket

saewoohan·2024년 5월 25일
0

Computer Network

목록 보기
3/14
post-thumbnail

해당 포스팅은 한양대학교 이석복 교수님의 컴퓨터네트워크 강의를 정리한 글입니다.
http://www.kocw.net/home/search/kemView.do?kemId=1169634

1. Socket

  • application과 network 사이의 interface이다.
  • 단순히 말하자면, 클라이언트와 서버 사이의 통신 방식이다.

1) Two essential types of sockes

  1. SOCK_STREAM
  • a.k.a TCP
  • 신뢰도 있는 전달
  • 순서의 보장
  • connection-oriented
  • 양방향 통신
  1. SOCK_DGRAM
  • a.k.a UDP
  • 신뢰도 없는 전달
  • 순서가 보장되지 않음.
  • connection이 필요 없음
  • 전달 또는 받기 가능

2) Socket의 순서 (TCP)

a) Client

  1. connection을 server측에 요청한다. (TCP three-way handshaking)
  2. write (data request)
  3. read (서버측에서 받은 data)
  4. close

b) Server

  1. socket 생성
  2. bind (소켓을 특정 port에 바인딩 하는 과정)
  3. listen
  4. accpet (준비 완료, 클라이언트부터 connect를 받기 전까지 block 상태)
  5. read (클라이언트 측에서 받은 data)
  6. write (서버측도 write 가능)
  7. read (클라이언트에서 보내온 close 신호)
  8. close

3) Socket의 순서 (UDP)

  • handshake (connection 과정이 없다.)

a) Client

  1. socket 생성
  2. server측에 데이터 send
  3. server측에서 data receive
  4. close

b) Server

  1. socket 생성
  2. bind (port binding)
  3. client측에서 data receive
  4. client측에 data send

2. Multiplexing/demultiplextion

  • receive 측에서는 segments (TCP의 payload)를 알맞은 socket에 보낸다 -> Demultiplexing
  • sender 측에서는 다양한 소켓에서 데이터를 모아 header로 감싼다 -> Multiplexing

  • TCP는 IP주소와 PORT를 통해서 다른 socket과 구별해서 옮긴다.
  • UDP는 PORT만 보기에 다 같은 socket으로 들어가게 된다.
    즉, TCP는 header에 IP주소 값도 포함되어야 한다.

0개의 댓글