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

Function connect_server

lib_acl_cpp/samples/aio/aio_connect/main.cpp:166–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164};
165
166static 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
197static void usage(const char* procname)
198{

Callers 2

open_callbackMethod · 0.70
mainFunction · 0.70

Calls 7

openFunction · 0.85
acl_tcp_so_lingerFunction · 0.85
add_open_callbackMethod · 0.80
add_close_callbackMethod · 0.80
add_timeout_callbackMethod · 0.80
stopMethod · 0.45
get_vstreamMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…