-
Notifications
You must be signed in to change notification settings - Fork 44
/
miniwebsock.h
84 lines (67 loc) · 1.02 KB
/
miniwebsock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <glib/gi18n.h>
#ifndef _MINIWEBSOCK_H_
#define _MINIWEBSOCK_H_
typedef enum
{
frame_none,
frame_text,
frame_binary,
frame_close,
frame_ping,
frame_pong
} frame_type;
typedef enum
{
last_frame,
not_last_frame
} frame_in_queue;
typedef struct __attribute__((__packed__)) _frame_value_
{
frame_type type;
frame_in_queue last;
guchar* data;
} frame_value;
struct __attribute__((__packed__)) frame_header_0
{
guint8 header;
guint8 mask_len;
guint32 mask;
};
struct __attribute__((__packed__)) frame_header_2
{
guint8 header;
guint8 mask_len;
guint16 len;
guint32 mask;
};
struct __attribute__((__packed__)) frame_header_8
{
guint8 header;
guint8 mask_len;
guint64 len;
guint32 mask;
};
extern const struct frame_header_0 final_frame;
/*
* functions
*/
int
start_websocket_session(
int socket_fd,
gchar *host,
gchar *req
);
int
close_websocket_session(
int socket_fd
);
frame_value
poll_frame(
int socket_fd
);
int
send_text_frame(
int socket_fd,
const char* text
);
#endif