| 164 | }; |
| 165 | |
| 166 | static bool connect_server(IO_CTX* ctx, int id) |
| 167 | { |
| 168 | // ��ʼ�첽����Զ�̷����� |
| 169 | acl::aio_socket_stream* stream = acl::aio_socket_stream::open |
| 170 | (ctx->handle, ctx->addr, ctx->connect_timeout); |
| 171 | if (stream == NULL) { |
| 172 | std::cout << "connect " << ctx->addr << " error!" << std::endl; |
| 173 | std::cout << "stoping ..." << std::endl; |
| 174 | if (id == 0) { |
| 175 | ctx->handle->stop(); |
| 176 | } |
| 177 | return false; |
| 178 | } |
| 179 | |
| 180 | ACL_VSTREAM *fp = stream->get_vstream(); |
| 181 | acl_tcp_so_linger(ACL_VSTREAM_SOCK(fp), 1, 0); |
| 182 | |
| 183 | // �������Ӻ�Ļص������� |
| 184 | client_io_callback* callback = new client_io_callback(ctx, stream, id); |
| 185 | |
| 186 | // �������ӳɹ��Ļص������� |
| 187 | stream->add_open_callback(callback); |
| 188 | |
| 189 | // ��������ʧ�ܺ�ص������� |
| 190 | stream->add_close_callback(callback); |
| 191 | |
| 192 | // �������ӳ�ʱ�Ļص������� |
| 193 | stream->add_timeout_callback(callback); |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | static void usage(const char* procname) |
| 198 | { |
no test coverage detected
searching dependent graphs…