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

Method read_callback

lib_acl_cpp/samples/winaio/AioClient.cpp:31–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31bool CConnectClientCallback::read_callback(char* data, int len)
32{
33 (void) data;
34 (void) len;
35
36 ctx_->nread_total++;
37
38 if (ctx_->debug)
39 {
40 if (nwrite_ < 10)
41 std::cout << "gets(" << nwrite_ << "): " << data;
42 else if (nwrite_ % 2000 == 0)
43 std::cout << ">>ID: " << id_ << ", I: "
44 << nwrite_ << "; "<< data;
45 }
46
47 // ����յ����������˳���Ϣ����ҲӦ�˳�
48 if (strncasecmp(data, "quit", 4) == 0)
49 {
50 // ���������������
51 client_->format("Bye!\r\n");
52 // �ر��첽������
53 client_->close();
54 return (true);
55 }
56
57 if (nwrite_ >= ctx_->nwrite_limit)
58 {
59 if (ctx_->debug)
60 std::cout << "ID: " << id_
61 << ", nwrite: " << nwrite_
62 << ", nwrite_limit: " << ctx_->nwrite_limit
63 << ", quiting ..." << std::endl;
64
65 // ������������˳���Ϣ
66 client_->format("quit\r\n");
67 client_->close();
68 }
69 else
70 {
71 char buf[256];
72 snprintf(buf, sizeof(buf), "hello world: %d\n", nwrite_);
73 client_->write(buf, (int) strlen(buf));
74
75 // ���������������
76 //client_->format("hello world: %d\n", nwrite_);
77 }
78
79 return (true);
80}
81
82bool CConnectClientCallback::write_callback()
83{

Callers

nothing calls this directly

Calls 4

strncasecmpFunction · 0.85
formatMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected