-
-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
websocket_server_write_frame_header函数建议返回头部长度,这样使用完这个函数可以得到dst应该偏移多少,比如如下
static ngx_inline int
websocket_server_write_frame_header(u_char *dst, u_char opcode,
size_t payload_length)
{
dst[0] = (u_char)((opcode & 0x0F) | 0x80);
if ( payload_length <= 125 ) {
dst[1] = (u_char)(payload_length);
return 2;
}
dst[1] = (u_char) 126;
*(u_short *)&(dst[2]) = htons((u_short)(payload_length));
return 4;
}
使用时:
...
int len = websocket_server_write_frame_header(dst, opcode, payload_length);
dst += len;
...
Metadata
Metadata
Assignees
Labels
No labels