Reputation: 51928
What's the purpose of using binary data for websockets. Is it mainly for encryption purposes, or does it make anything faster or better than regular text?
For example: https://github.com/websockets/ws
Shows how to send and receive binary data. But I'm not sure what I'd use that for.
Upvotes: 2
Views: 2806
Reputation: 130
Binary vs text is not necessary a WebSocket-related issue. It is a fundamental difference in data format for computing particularly for data transmission. Very roughly speaking, binary format is smaller, it is used for encryption (as you correctly point out), its use for compression of large data sets, its used for multimedia (images, sound) and generally faster to send over the wire. Binary is the natural language of the computer. Text is the natural language of humans. It typically is readable... as long as its translated... ;) Text is usually easier to deal with in programs and is usually easier to use as a data format within computer programs (since we're human).
Which one you use is based on the requirements of your program, both functional and performance.
WebSocket is just a means to send the data (in either text or binary) from once place to another using a web-friendly protocol.
Upvotes: 4
Reputation: 46323
Binary is the most basic form of data. If your communication mechanism supports binary data, it supports all data without special treatment (encoding).
For that reason, any communication mechanism that supports binary transmission would want to express that ability.
Upvotes: 0