| 149 | } |
| 150 | |
| 151 | bool CConnectClientCallback::connect_server(IO_CTX* ctx, int id) |
| 152 | { |
| 153 | // ��ʼ�첽����Զ�̷����� |
| 154 | // const char* addr = "221.194.139.155:18887"; |
| 155 | // ctx->connect_timeout = 1; |
| 156 | aio_socket_stream* stream = aio_socket_stream::open(ctx->handle, |
| 157 | ctx->addr, ctx->connect_timeout); |
| 158 | if (stream == NULL) |
| 159 | { |
| 160 | std::cout << "connect " << ctx->addr << " error!" << std::endl; |
| 161 | std::cout << "stoping ..." << std::endl; |
| 162 | if (id == 0) |
| 163 | ctx->handle->stop(); |
| 164 | return (false); |
| 165 | } |
| 166 | |
| 167 | // �������Ӻ�Ļص������� |
| 168 | CConnectClientCallback* callback = new CConnectClientCallback(ctx, stream, id); |
| 169 | |
| 170 | // �������ӳɹ��Ļص������� |
| 171 | stream->add_open_callback(callback); |
| 172 | |
| 173 | // ��������ʧ�ܺ�ص������� |
| 174 | stream->add_close_callback(callback); |
| 175 | |
| 176 | // �������ӳ�ʱ�Ļص������� |
| 177 | stream->add_timeout_callback(callback); |
| 178 | return (true); |
| 179 | } |
nothing calls this directly
no test coverage detected