Skip to content

Commit bb014a9

Browse files
[웹소켓] 충북대 특강 실습용
1 parent 07c70c0 commit bb014a9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

5-network/11-websocket/article.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,31 +160,31 @@ Sec-WebSocket-Protocol: soap
160160
161161
이 경우, 우리는 서버에선 'deflate-frame'이라는 익스텐션과 요청 프로토콜 중 SOAP라는 서브 프로토콜만 지원한다는 사실을 알 수 있습니다.
162162
163-
## Data transfer
163+
## 데이터 전송
164164
165-
WebSocket communication consists of "frames" -- data fragments, that can be sent from either side, and can be of several kinds:
165+
웹소켓 통신은 '프레임(frame)'이라 불리는 데이터 조각을 사용해 이뤄집니다. 프레임은 서버와 클라이언트 양측 모두에서 보낼 수 있는데 프레임 내 담긴 데이터 종류에 따라 다음과 같이 분류할 수 있습니다.
166166
167-
- "text frames" -- contain text data that parties send to each other.
168-
- "binary data frames" -- contain binary data that parties send to each other.
169-
- "ping/pong frames" are used to check the connection, sent from the server, the browser responds to these automatically.
170-
- there's also "connection close frame" and a few other service frames.
167+
- 텍스트 프레임(text frame) -- 텍스트 데이터가 담긴 프레임
168+
- 이진 데이터 프레임(binary data frame) -- 이진 데이터가 담긴 프레임
169+
- 핑 또는 퐁 프레임(ping/pong frame) -- 커넥션이 유지되고 있는지 확인할 때 사용하는 프레임으로 서버나 브라우저에서 자동 생성해서 보내는 프레임
170+
- 이 외에도 '커넥션 종료 프레임(connection close frame) 등 다양한 프레임이 있음
171171
172-
In the browser, we directly work only with text or binary frames.
172+
브라우저 환경에서 개발자는 텍스트나 이진 프레임만 다루게 됩니다.
173173
174-
**WebSocket `.send()` method can send either text or binary data.**
174+
이유는 **WebSocket `.send()` 메서드는 텍스트나 바이너리 데이터만 보낼 수 있기 때문입니다.**
175175
176-
A call `socket.send(body)` allows `body` in string or a binary format, including `Blob`, `ArrayBuffer`, etc. No settings required: just send it out in any format.
176+
`socket.send(body)`를 호출할 때, `body`엔 문자열이나 `Blob`, `ArrayBuffer`등의 이진 데이터만 들어갈 수 있습니다. 데이터 종류에 따라 특별히 무언가 세팅을 해줘야 할 필요는 없고, 텍스트나 바이너리 타입의 데이터를 넣어주면 알아서 데이터가 전송됩니다.
177177
178-
**When we receive the data, text always comes as string. And for binary data, we can choose between `Blob` and `ArrayBuffer` formats.**
178+
한편, **데이터를 받을 때, 텍스트 데이터는 항상 문자열 형태로 옵니다. 이진 데이터를 받을 때엔 `Blob`이나 `ArrayBuffer` 포맷 둘 중 하나를 고를 수 있습니다.**
179179
180-
That's set by `socket.binaryType` property, it's `"blob"` by default, so binary data comes as `Blob` objects.
180+
`socket.binaryType` 프로퍼티를 사용하면 `Blob`이나 `ArrayBuffer` 포맷 둘 중 하나를 고를 수 있는데, 프로퍼티 기본값은 `"blob"`이라서 이진 데이터는 기본적으로 `Blob` 객체 형태로 전송받게 됩니다.
181181
182-
[Blob](info:blob) is a high-level binary object, it directly integrates with `<a>`, `<img>` and other tags, so that's a sane default. But for binary processing, to access individual data bytes, we can change it to `"arraybuffer"`:
182+
[Blob](info:blob)은 고차원(high-level)의 이진 객체인데, `<a>` `<img>` 등의 태그와 바로 통합할 수 있어서 기본값으로 아주 적절합니다. 하지만 이진 데이터를 처리하는 과정에 개별 데이터 바이트에 접근해야 하는 경우엔 프로퍼티 값을 `"arraybuffer"`로 바꿀 수도 있습니다.
183183
184184
```js
185185
socket.binaryType = "arraybuffer";
186186
socket.onmessage = (event) => {
187-
// event.data is either a string (if text) or arraybuffer (if binary)
187+
// event.data는 (텍스트인 경우) 문자열이거나 (이진 데이터인 경우) arraybuffer 입니다.
188188
};
189189
```
190190

0 commit comments

Comments
 (0)