* �����麯��, ���첽���ӳɹ�����ô˺��� * @return {bool} ���ظ������� true ��ʾ�����������ʾ��Ҫ�ر��첽�� */
| 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 | |
| 201 | private: |
| 202 | acl::aio_socket_stream* client_; |
nothing calls this directly
no test coverage detected