Websocket: what is the purpose text/binary frame indicator -
i implementing websocket server in c , wondering what's purpose of text/binary frame indicators (opcode 1 , 2). why there? in end in both cases payload contains bits. , when there protocol using websocket or know expect in data. because when it's text message can sure payload contains utf-8 valid data?
i start answer pointing out websockets implemented javascript client in mind (i.e., browser).
when you're using c, different opcode might used in different ways, when using javascript, difference controls type of data in event (blob vs. string).
as point out in question, string valid utf-8 stream of bytes, whereas blob isn't.
this affects data transport schemes (such json parsing, requires utf-8 valid stream).
obviously, in c, opcode used in different ways, better use opcode in same manner potential javascript client.
p.s.
there number of websocket c libraries , frameworks out there (i'm author of facil.io).
unless study project, consider using 1 of established frameworks / libraries.
Comments
Post a Comment