작성
·
9
답변 1
1
서버는 port를 열어두고 listening상태에서 대기하고 있고, client가 http request를 보내 initial handshake를 시작하게 됩니다. initial handshake를 보낼 때 http header에 connection을 websocket으로 upgrade하고 싶다고 요청하게 됩니다. server가 handshake을 accept하면 websocket이 연결되게 됩니다.
연결을 끊는 것은 closing handshake에 의해 이루어지고, closing은 server나 client 어느쪽도 먼저 시작할 수 있습니다.
백그라운드 상태에서도 "persistent"한 연결이 유지됩니다. websocket이 연결되면, full-duplex, persistent TCP connection이라고 생각하시면 됩니다.