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

Method open_callback

lib_acl_cpp/samples/aio/aio_client/main.cpp:173–199  ·  view source on GitHub ↗

* �����麯��, ���첽���ӳɹ�����ô˺��� * @return {bool} ���ظ������� true ��ʾ�����������ʾ��Ҫ�ر��첽�� */

Source from the content-addressed store, hash-verified

171 * @return {bool} ���ظ������� true ��ʾ�����������ʾ��Ҫ�ر��첽��
172 */
173 bool open_callback(void)
174 {
175 // ���ӳɹ�������IO��д�ص�����
176 client_->add_read_callback(this);
177 client_->add_write_callback(this);
178 ctx_->nopen_total++;
179
180 acl::assert_(id_ > 0);
181 if (ctx_->nopen_total < ctx_->nopen_limit) {
182 // ��ʼ������һ�����ӹ���
183 if (connect_server(ctx_, id_ + 1) == false) {
184 std::cout << "connect error!" << std::endl;
185 }
186 }
187
188 // �첽���������������
189 //client_->format("hello world: %d\n", nwrite_);
190 char buf[256];
191 snprintf(buf, sizeof(buf), "hello world: %d\n", nwrite_);
192 client_->write(buf, (int) strlen(buf));
193
194 // �첽�ӷ�������ȡһ������
195 client_->gets(ctx_->read_timeout, false);
196
197 // ��ʾ�����첽����
198 return true;
199 }
200
201private:
202 acl::aio_socket_stream* client_;

Callers

nothing calls this directly

Calls 6

assert_Function · 0.85
add_read_callbackMethod · 0.80
add_write_callbackMethod · 0.80
getsMethod · 0.80
connect_serverFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected