| 121 | } |
| 122 | |
| 123 | bool CConnectClientCallback::open_callback() |
| 124 | { |
| 125 | // ���ӳɹ�������IO��д�ص����� |
| 126 | client_->add_read_callback(this); |
| 127 | client_->add_write_callback(this); |
| 128 | ctx_->nopen_total++; |
| 129 | |
| 130 | acl_assert(id_ > 0); |
| 131 | if (ctx_->nopen_total < ctx_->nopen_limit) |
| 132 | { |
| 133 | // ��ʼ������һ�����ӹ��� |
| 134 | if (connect_server(ctx_, id_ + 1) == false) |
| 135 | std::cout << "connect error!" << std::endl; |
| 136 | } |
| 137 | |
| 138 | // �첽��������������� |
| 139 | //client_->format("hello world: %d\n", nwrite_); |
| 140 | char buf[256]; |
| 141 | snprintf(buf, sizeof(buf), "hello world: %d\n", nwrite_); |
| 142 | client_->write(buf, (int) strlen(buf)); |
| 143 | |
| 144 | // �첽�ӷ�������ȡһ������ |
| 145 | client_->gets(ctx_->read_timeout, false); |
| 146 | |
| 147 | // ��ʾ�����첽���� |
| 148 | return (true); |
| 149 | } |
| 150 | |
| 151 | bool CConnectClientCallback::connect_server(IO_CTX* ctx, int id) |
| 152 | { |
nothing calls this directly
no test coverage detected