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

Method read_callback

lib_acl_cpp/samples/ssl/aio_server/main.cpp:91–125  ·  view source on GitHub ↗

* ʵ�ָ����е��麯�����ͻ������Ķ��ɹ��ص����� * @param data {char*} ���������ݵ�ַ * @param len {int} ���������ݳ��� * @return {bool} ���� true ��ʾ����������ϣ���رո��첽�� */

Source from the content-addressed store, hash-verified

89 * @return {bool} ���� true ��ʾ����������ϣ���رո��첽��
90 */
91 bool read_callback(char* data, int len)
92 {
93 nread_cnt_++;
94 nread_ += len;
95
96 if (nread_cnt_ <= 100 || nread_cnt_ % 1000 == 0) {
97 char buf[256];
98 acl::safe_snprintf(buf, sizeof(buf),
99 "read len: %d, total read: %d, nread_cnt: %d",
100 len, nread_, nread_cnt_);
101 acl::meter_time(__FILE__, __LINE__, buf);
102 }
103
104 // ���Զ�̿ͻ���ϣ���˳�����ر�֮
105 if (strncasecmp(data, "quit", 4) == 0) {
106 client_->format("Bye!\r\n");
107 client_->close();
108 return true;
109 }
110
111 // ���Զ�̿ͻ���ϣ�������Ҳ�رգ�����ֹ�첽�¼�����
112 if (strncasecmp(data, "stop", 4) == 0) {
113 client_->format("Stop now!\r\n");
114 client_->close(); // �ر�Զ���첽��
115
116 // ֪ͨ�첽����ر�ѭ������
117 client_->get_handle().stop();
118 }
119
120 //printf(">>data=%s\n", data);
121 // ��Զ�̿ͻ��˻�д�յ�������
122
123 client_->write(data, len);
124 return true;
125 }
126
127 /**
128 * ʵ�ָ����е��麯�����ͻ�������д�ɹ��ص�����

Callers

nothing calls this directly

Calls 8

safe_snprintfFunction · 0.85
meter_timeFunction · 0.85
strncasecmpFunction · 0.85
formatMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45
get_handleMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected