socket.io 채팅 (1)

BirdsOnTree·2022년 9월 5일
0

Javascript

목록 보기
11/17
post-thumbnail

채팅의 2가지 protocol 방식 (TCP [주로 사용] , UDP)

socket() : 소켓 생성 (Client, Server)
bind() : 소켓에 주소 할당(IP, port) (Server)
listen() : 소켓이 연결을 받아들이기 위한 상태로 전환 (Server)
connect() : 클라이언트에서 소켓 생성 후, server로 연결 요청 (Client)
accept() : 클라이언트로부터의 연결 요청 수락 (Server)
send(), recv() : 데이터 송수신 (Client, Server)
emit() : 데이터 전송 (Client, Server)
on() : 데이터를 받음 (Client, Server)
close() : 연결 종료 (Client)

Client >> connect >> Server

connect()로 서버로 연결되었다.

Client << Data << Server

Client >> Data >> Server

Client << Data << Server

Client >> Data >> Server

클라이언트와 서버가 서로 데이터를 주고 받는다.

Client >> close >> Server

close()를 통해 연결이 끊어짐

참고: 루시오의 Devlog
https://roothyo.tistory.com/41?category=1033490

0개의 댓글