MCPcopy Create free account
hub / github.com/acl-dev/acl / read_reply

Function read_reply

lib_acl_cpp/samples/websocket/upload_client/main.cpp:89–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static bool read_reply(acl::websocket& ws)
90{
91 if (!ws.read_frame_head()) {
92 printf("read_frame_head error %s\r\n", acl::last_serror());
93 return false;
94 }
95
96 char cbuf[1024];
97 unsigned char opcode = ws.get_frame_opcode();
98 switch (opcode) {
99 case acl::FRAME_TEXT:
100 case acl::FRAME_BINARY:
101 break;
102 default:
103 printf("invalid opcode: 0x%x\r\n", opcode);
104 return false;
105 }
106
107 int ret = ws.read_frame_data(cbuf, sizeof(cbuf) - 1);
108 if (ret <= 0) {
109 printf("read_frame_data error\r\n");
110 return false;
111 }
112 cbuf[ret] = 0;
113 printf("reply from server: %s, len: %d\r\n", cbuf, ret);
114
115 return true;
116}
117
118static bool upload(const char* addr, const char* filepath)
119{

Callers 1

uploadFunction · 0.85

Calls 3

read_frame_headMethod · 0.80
read_frame_dataMethod · 0.80
last_serrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…