这篇教程C++ uv_accept函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中uv_accept函数的典型用法代码示例。如果您正苦于以下问题:C++ uv_accept函数的具体用法?C++ uv_accept怎么用?C++ uv_accept使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了uv_accept函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _tcp_acceptstatic void _tcp_accept(uv_stream_t *master, int status, bool tls){ if (status != 0) { return; } uv_stream_t *client = handle_alloc(master->loop); if (!client) { return; } memset(client, 0, sizeof(*client)); io_create(master->loop, (uv_handle_t *)client, SOCK_STREAM); if (uv_accept(master, client) != 0) { uv_close((uv_handle_t *)client, io_free); return; } /* Set deadlines for TCP connection and start reading. * It will re-check every half of a request time limit if the connection * is idle and should be terminated, this is an educated guess. */ struct session *session = client->data; session->has_tls = tls; if (tls && !session->tls_ctx) { session->tls_ctx = tls_new(master->loop->data); } uv_timer_t *timer = &session->timeout; uv_timer_init(master->loop, timer); timer->data = client; uv_timer_start(timer, tcp_timeout_trigger, KR_CONN_RTT_MAX/2, KR_CONN_RTT_MAX/2); io_start_read((uv_handle_t *)client);}
开发者ID:Karm,项目名称:knot-resolver,代码行数:30,
示例2: SocketAcceptint SocketAccept(uv_stream_t *const sstream, struct tls *const ssecure, SocketRef *const out) { SocketRef socket = calloc(1, sizeof(struct Socket)); if(!socket) return UV_ENOMEM; int rc = uv_tcp_init(async_loop, socket->stream); if(rc < 0) goto cleanup; rc = uv_accept(sstream, (uv_stream_t *)socket->stream); if(rc < 0) goto cleanup; if(ssecure) { uv_os_fd_t fd; rc = uv_fileno((uv_handle_t *)socket->stream, &fd); if(rc < 0) goto cleanup; for(;;) { int event = tls_accept_socket(ssecure, &socket->secure, fd); if(0 == event) break; rc = tls_poll((uv_stream_t *)socket->stream, event); if(rc < 0) goto cleanup; } } socket->rdmem = NULL; *socket->rd = uv_buf_init(NULL, 0); *socket->wr = uv_buf_init(NULL, 0); *out = socket; socket = NULL;cleanup: SocketFree(&socket); return rc;}
开发者ID:Ryezhang,项目名称:stronglink,代码行数:26,
示例3: connection_cbstatic void connection_cb(uv_stream_t *server, int status) { uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t)); GPR_ASSERT(0 == status); GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), client_handle)); GPR_ASSERT(0 == uv_accept(server, (uv_stream_t *)client_handle)); uv_close((uv_handle_t *)client_handle, close_cb);}
开发者ID:endobson,项目名称:grpc,代码行数:7,
示例4: onconnectionstatic void onconnection(uv_stream_t *server, int status) { CHECK(status, "onconnection"); int r = 0; uv_shutdown_t *shutdown_req; /* 4. Accept client connection */ log_info("Accepting Connection"); /* 4.1. Init client connection using `server->loop`, passing the client handle */ uv_tcp_t *client = malloc(sizeof(uv_tcp_t)); r = uv_tcp_init(server->loop, client); CHECK(r, "uv_tcp_init"); /* 4.2. Accept the now initialized client connection */ r = uv_accept(server, (uv_stream_t*) client); if (r) { log_error("trying to accept connection %d", r); shutdown_req = malloc(sizeof(uv_shutdown_t)); r = uv_shutdown(shutdown_req, (uv_stream_t*) client, shutdown_cb); CHECK(r, "uv_shutdown"); } /* 5. Start reading data from client */ r = uv_read_start((uv_stream_t*) client, alloc_cb, read_cb); CHECK(r, "uv_read_start");}
开发者ID:Ryannnnnnn,项目名称:learnuv,代码行数:28,
示例5: Server_newTCPConnectionstatic void Server_newTCPConnection( uv_stream_t *server, int status ) { if ( status < 0 ) { log_warn( "Connection error: %s", uv_err_name( status ) ); return; } dbg_info( "Connection received." ); ClientConnection *client = Client_new( ); if ( !client ) goto badClient; client->handle.tcpHandle = malloc( sizeof(*client->handle.tcpHandle) ); if ( !client->handle.tcpHandle ) goto badHandle; uv_tcp_init( server->loop, client->handle.tcpHandle ); client->handle.tcpHandle->data = client; if ( uv_accept( server, client->handle.stream ) == 0 ) { client->server = server->data;#if defined(CLIENTTIMEINFO) client->startTime = uv_now( server->loop );#endif Client_handleConnection( client ); } else { Client_terminate( client ); } return;badHandle: Client_free( client );badClient: return;}
开发者ID:torque,项目名称:reki,代码行数:32,
示例6: oc_cluster_acceptint oc_cluster_accept(oc_cluster_t *cluster, uv_stream_t* server) { uv_tcp_t *client; oc_worker_t *worker; int err; client = (uv_tcp_t*)malloc(sizeof(uv_tcp_t)); if (client == NULL) { // oom return -1; } uv_tcp_init(cluster->loop, client); err = uv_accept(server, (uv_stream_t*)client); if (err != 0) { err = -1; goto cleanup; } worker = pick_worker(cluster->workers, cluster->count); oc_worker_forward(worker, client); return 0;cleanup: uv_close((uv_handle_t*)client, NULL); return err;}
开发者ID:kvanberendonck,项目名称:ocelot,代码行数:29,
示例7: api_newconnstatic voidapi_newconn (uv_stream_t *req, int status){ Api *api = (Api *) req; int rc = 0; debug ("init client"); rc = uv_pipe_init ((SERVER_FROM_API (api))->loop, &api->client, 0); if (rc < 0) goto error; debug ("accept client"); rc = uv_accept ((uv_stream_t *) api, (uv_stream_t *) &api->client); if (rc < 0) goto error; debug ("listen client"); rc = uv_read_start ((uv_stream_t *) &api->client, api_alloc_cb, api_cb); if (rc < 0) goto error; return;error: debug ("closing client"); uv_close ((uv_handle_t *) &api->client, NULL); if (rc) debug ("error: %s", uv_strerror (rc)); return;}
开发者ID:amstocker,项目名称:gossip,代码行数:30,
示例8: do_acceptstatic void do_accept(uv_req_t* req, int64_t skew, int status) { uv_handle_t* server; uv_handle_t* accepted_handle = (uv_handle_t*)malloc(sizeof *accepted_handle); int r; ASSERT(req != NULL); ASSERT(status == 0); ASSERT(accepted_handle != NULL); server = (uv_handle_t*)req->data; r = uv_accept(server, accepted_handle, close_cb, NULL); ASSERT(r == 0); do_accept_called++; /* Immediately close the accepted handle. */ uv_close(accepted_handle); /* After accepting the two clients close the server handle */ if (do_accept_called == 2) { uv_close(server); } free(req);}
开发者ID:FrostedDarkness,项目名称:node,代码行数:25,
示例9: on_connection/** * CB for new connection requests. */void on_connection(uv_stream_t *server, int status){ if (status < 0) { fprintf(stderr, "New connection error: %s/n", uv_strerror(uv_last_error(server->loop))); return; } client_t *clnt = (client_t *)malloc(sizeof(client_t)); client_init(clnt); uv_tcp_init(server->loop, &clnt->source); if (uv_accept(server, (uv_stream_t *)&clnt->source) != 0) { fprintf(stderr, "Accept failed: %s/n", uv_strerror(uv_last_error(server->loop))); uv_close((uv_handle_t *)&clnt->source, NULL); free(clnt); return; } // succesfull accept here clnt->source.data = (void *)clnt; uv_read_start((uv_stream_t *)&clnt->source, alloc_buffer, on_read); // unref server to force program termination when client disconnects uv_unref((uv_handle_t *)server);}
开发者ID:hrautila,项目名称:glme,代码行数:30,
示例10: _http_conn_new/* _http_conn_new(): create http connection.*/static void_http_conn_new(u3_http *htp_u){ u3_hcon *hon_u = c3_malloc(sizeof(*hon_u)); uv_tcp_init(u3L, &hon_u->wax_u); c3_w ret_w; ret_w = uv_accept((uv_stream_t*)&htp_u->wax_u, (uv_stream_t*)&hon_u->wax_u); if (ret_w == UV_EOF) { uL(fprintf(uH, "http: accept: ERROR/n")); uv_close((uv_handle_t*)&hon_u->wax_u, _http_conn_free_early); } else { uv_read_start((uv_stream_t*)&hon_u->wax_u, _http_alloc, _http_conn_read_cb); hon_u->coq_l = htp_u->coq_l++; hon_u->seq_l = 1; hon_u->ruc_u = 0; hon_u->req_u = 0; hon_u->qer_u = 0; hon_u->htp_u = htp_u; hon_u->nex_u = htp_u->hon_u; htp_u->hon_u = hon_u; }}
开发者ID:dphiffer,项目名称:urbit,代码行数:35,
示例11: lua_uv_stream_acceptint lua_uv_stream_accept(lua_State * L) { uv_stream_t * server = lua_generic_object<uv_stream_t>(L, 1); uv_stream_t * client = lua_generic_object<uv_stream_t>(L, 2); uv_accept(server, client); lua_uv_ok(L); return 0;}
开发者ID:grrrwaaa,项目名称:luauv,代码行数:7,
示例12: connection_cbstatic void connection_cb(uv_stream_t* s, int status) { uv_stream_t* stream; int r; ASSERT(server == s); ASSERT(status == 0); if (type == TCP) { stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t)); r = uv_tcp_init(loop, (uv_tcp_t*)stream); ASSERT(r == 0); } else { stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t)); r = uv_pipe_init(loop, (uv_pipe_t*)stream); ASSERT(r == 0); } r = uv_accept(s, stream); ASSERT(r == 0); r = uv_read_start(stream, buf_alloc, read_cb); ASSERT(r == 0); read_sockets++; max_read_sockets++;}
开发者ID:178620086,项目名称:Node4Android,代码行数:26,
示例13: do_acceptstatic void do_accept(uv_handle_t* timer_handle, int status) { uv_handle_t* server; uv_handle_t* accepted_handle = (uv_handle_t*)malloc(sizeof *accepted_handle); int r; ASSERT(timer_handle != NULL); ASSERT(status == 0); ASSERT(accepted_handle != NULL); server = (uv_handle_t*)timer_handle->data; r = uv_accept(server, accepted_handle, close_cb, NULL); ASSERT(r == 0); do_accept_called++; /* Immediately close the accepted handle. */ r = uv_close(accepted_handle); ASSERT(r == 0); /* After accepting the two clients close the server handle */ if (do_accept_called == 2) { r = uv_close(server); ASSERT(r == 0); } /* Dispose the timer. */ r = uv_close(timer_handle); ASSERT(r == 0);}
开发者ID:amb26,项目名称:node,代码行数:29,
示例14: connection_cbvoid connection_cb(uv_stream_t *server, int status) { int r; if (status) { fprintf(stderr, "connection error %d", status); return; } // main diff between uv_tcp_t and uv_pipe_t is the ipc flag and the pipe_fname pointing to local sock file uv_pipe_t *client = (uv_pipe_t*) malloc(sizeof(uv_pipe_t)); uv_pipe_init(loop, client, NOIPC); r = uv_accept(server, (uv_stream_t*) client); if (r == 0) { uv_write_t *write_req = (uv_write_t*) malloc(sizeof(uv_write_t)); dummy_buf = uv_buf_init(".", 1); struct child_worker *worker = &workers[round_robin_counter]; // Extended write function for sending handles over a pipe // https://github.com/thlorenz/libuv-dox/blob/master/methods.md#uv_write2 uv_write2(write_req, (uv_stream_t*) &worker->pipe, &dummy_buf, 1 /*nbufs*/, (uv_stream_t*) client, NULL); round_robin_counter = (round_robin_counter + 1) % child_worker_count; } else { uv_close((uv_handle_t*) client, NULL); }}
开发者ID:cloud-hot,项目名称:libuv-dox,代码行数:27,
示例15: _listen_cbstatic void _listen_cb(uv_stream_t* server, int status) { TRACE("got client connection.../n"); luv_object_t* self = container_of(server, luv_object_t, h); if (luvL_object_is_waiting(self)) { ngx_queue_t* q = ngx_queue_head(&self->rouse); luv_state_t* s = ngx_queue_data(q, luv_state_t, cond); lua_State* L = s->L; TRACE("is waiting..., lua_State*: %p/n", L); luaL_checktype(L, 2, LUA_TUSERDATA); luv_object_t* conn = (luv_object_t*)lua_touserdata(L, 2); TRACE("got client conn: %p/n", conn); luvL_object_init(s, conn); int rv = uv_accept(&self->h.stream, &conn->h.stream); TRACE("accept returned ok/n"); if (rv) { uv_err_t err = uv_last_error(self->h.stream.loop); TRACE("ERROR: %s/n", uv_strerror(err)); lua_settop(L, 0); lua_pushnil(L); lua_pushstring(L, uv_strerror(err)); } self->flags &= ~LUV_OWAITING; luvL_cond_signal(&self->rouse); } else { TRACE("increment backlog count/n"); self->count++; }}
开发者ID:Strongc,项目名称:luv,代码行数:30,
示例16: uv_tcp_initint TcpServer::Accept() { uv_tcp_t* handle = new uv_tcp_t; int result = uv_tcp_init( m_loop, handle ); assert( result == 0 ); result = uv_accept( reinterpret_cast<uv_stream_t*>( &m_server ), reinterpret_cast<uv_stream_t*>( handle ) ); if ( result == -1 ) { uv_close( reinterpret_cast<uv_handle_t*>( handle ), TcpServer::OnCloseClient ); return -1; } result = uv_read_start( reinterpret_cast<uv_stream_t*>( handle ), TcpServer::OnAllocBuffer, TcpServer::OnRead ); if ( result == -1 ) { uv_close( reinterpret_cast<uv_handle_t*>( handle ), TcpServer::OnCloseClient ); return -1; } Client* p_client = new Client { this, handle }; handle->data = p_client; int id = s_next_client_id++; p_client->id = id; p_client->b_connected = true; m_clients.push_back( std::move( p_client ) ); m_client_id_map.insert( std::move( std::make_pair( id, p_client ) ) ); return id;}
开发者ID:jacres,项目名称:logger,代码行数:30,
示例17: ipc_on_connection_tcp_connstatic void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) { int r; uv_buf_t buf; uv_tcp_t* conn; ASSERT(status == 0); ASSERT((uv_stream_t*)&tcp_server == server); conn = malloc(sizeof(*conn)); ASSERT(conn); r = uv_tcp_init(server->loop, conn); ASSERT(r == 0); r = uv_accept(server, (uv_stream_t*)conn); ASSERT(r == 0); /* Send the accepted connection to the other process */ buf = uv_buf_init("hello/n", 6); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)conn, NULL); ASSERT(r == 0); r = uv_read_start((uv_stream_t*) conn, on_read_alloc, on_tcp_child_process_read); ASSERT(r == 0); uv_close((uv_handle_t*)conn, close_cb);}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:30,
示例18: socket_acceptstatic MVMObject * socket_accept(MVMThreadContext *tc, MVMOSHandle *h) { MVMIOSyncSocketData *data = (MVMIOSyncSocketData *)h->body.data; while (!data->accept_server) { uv_ref((uv_handle_t *)data->ss.handle); uv_run(tc->loop, UV_RUN_DEFAULT); } /* Check the accept worked out. */ if (data->accept_status < 0) { MVM_exception_throw_adhoc(tc, "Failed to listen: unknown error"); } else { uv_tcp_t *client = malloc(sizeof(uv_tcp_t)); uv_stream_t *server = data->accept_server; int r; uv_tcp_init(tc->loop, client); data->accept_server = NULL; if ((r = uv_accept(server, (uv_stream_t *)client)) == 0) { MVMOSHandle * const result = (MVMOSHandle *)MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIO); MVMIOSyncSocketData * const data = calloc(1, sizeof(MVMIOSyncSocketData)); data->ss.handle = (uv_stream_t *)client; data->ss.encoding = MVM_encoding_type_utf8; data->ss.sep = '/n'; result->body.ops = &op_table; result->body.data = data; return (MVMObject *)result; } else { uv_close((uv_handle_t*)client, NULL); free(client); MVM_exception_throw_adhoc(tc, "Failed to accept: %s", uv_strerror(r)); } }}
开发者ID:grondilu,项目名称:MoarVM,代码行数:35,
示例19: Pipe_func_acceptstatic PyObject *Pipe_func_accept(Pipe *self, PyObject *args){ int r; PyObject *client; RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); if (!PyArg_ParseTuple(args, "O:accept", &client)) { return NULL; } if (PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&StreamType)) { if (UV_HANDLE(client)->type != UV_TCP && UV_HANDLE(client)->type != UV_NAMED_PIPE) { PyErr_SetString(PyExc_TypeError, "Only TCP and Pipe objects are supported for accept"); return NULL; } } else if (PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&UDPType)) { /* empty */ } else { PyErr_SetString(PyExc_TypeError, "Only Stream and UDP objects are supported for accept"); return NULL; } r = uv_accept((uv_stream_t *)UV_HANDLE(self), (uv_stream_t *)UV_HANDLE(client)); if (r != 0) { RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_PipeError); return NULL; } Py_RETURN_NONE;}
开发者ID:ayanamist,项目名称:pyuv,代码行数:33,
示例20: TCP_func_acceptstatic PyObject *TCP_func_accept(TCP *self, PyObject *args){ int r; PyObject *client; RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); if (!PyArg_ParseTuple(args, "O:accept", &client)) { return NULL; } if (!PyObject_IsSubclass((PyObject *)client->ob_type, (PyObject *)&StreamType)) { PyErr_SetString(PyExc_TypeError, "Only stream objects are supported for accept"); return NULL; } r = uv_accept((uv_stream_t *)&self->tcp_h, (uv_stream_t *)UV_HANDLE(client)); if (r != 0) { RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_TCPError); return NULL; } Py_RETURN_NONE;}
开发者ID:eagles125,项目名称:pyuv,代码行数:26,
示例21: source_accept_cbvoidsource_accept_cb(uv_stream_t *server, int status) { struct source_context *source = new_source(); struct target_context *target = new_target(); source->target = target; target->source = source; uv_tcp_init(server->loop, &source->handle.tcp); uv_tcp_init(server->loop, &target->handle.tcp); uv_tcp_nodelay(&source->handle.tcp, 0); uv_tcp_nodelay(&target->handle.tcp, 0); uv_tcp_keepalive(&source->handle.tcp, 1, 60); uv_tcp_keepalive(&target->handle.tcp, 1, 60); int rc = uv_accept(server, &source->handle.stream); if (rc == 0) { connect_to_target(target); } else { logger_log(LOG_ERR, "accept error: %s", uv_strerror(rc)); close_source(source); close_target(target); }}
开发者ID:52M,项目名称:xSocks,代码行数:25,
示例22: do_acceptstatic void do_accept(uv_timer_t* timer_handle, int status) { uv_tcp_t* server; uv_tcp_t* accepted_handle = (uv_tcp_t*)malloc(sizeof *accepted_handle); int r; ASSERT(timer_handle != NULL); ASSERT(status == 0); ASSERT(accepted_handle != NULL); r = uv_tcp_init(uv_default_loop(), accepted_handle); ASSERT(r == 0); server = (uv_tcp_t*)timer_handle->data; r = uv_accept((uv_stream_t*)server, (uv_stream_t*)accepted_handle); ASSERT(r == 0); do_accept_called++; /* Immediately close the accepted handle. */ uv_close((uv_handle_t*)accepted_handle, close_cb); /* After accepting the two clients close the server handle */ if (do_accept_called == 2) { uv_close((uv_handle_t*)server, close_cb); } /* Dispose the timer. */ uv_close((uv_handle_t*)timer_handle, close_cb);}
开发者ID:2hanson,项目名称:node,代码行数:29,
示例23: read2_cbstatic void read2_cb(uv_pipe_t* handle, ssize_t nread, const uv_buf_t* rdbuf, uv_handle_type pending) { uv_buf_t wrbuf; int r; ASSERT(pending == UV_NAMED_PIPE || pending == UV_TCP); ASSERT(handle == &ctx.channel); ASSERT(nread >= 0); wrbuf = uv_buf_init(".", 1); if (pending == UV_NAMED_PIPE) r = uv_pipe_init(ctx.channel.loop, &ctx.recv.pipe, 0); else if (pending == UV_TCP) r = uv_tcp_init(ctx.channel.loop, &ctx.recv.tcp); else abort(); ASSERT(r == 0); r = uv_accept((uv_stream_t*)handle, &ctx.recv.stream); ASSERT(r == 0); r = uv_write2(&ctx.write_req, (uv_stream_t*)&ctx.channel, &wrbuf, 1, &ctx.recv.stream, write2_cb); ASSERT(r == 0);}
开发者ID:4T-Shirt,项目名称:node,代码行数:32,
示例24: server_on_connectionstatic void server_on_connection(uv_stream_t *handle, int status){ server_t *server = handle->data; // allocate client client_t *client = client_alloc(server->sizeof_client); // setup client client->server = server; // accept client // TODO: report errors uv_tcp_init(server->handle.loop, &client->handle); client->handle.data = client; // TODO: EMFILE trick! // https://github.com/joyent/libuv/blob/master/src/unix/ev/ev.3#L1812-1816 if (uv_accept((uv_stream_t *)&server->handle, (uv_stream_t *)&client->handle)) { // accept failed? report error client->server->on_event(server, EVT_ERROR, uv_last_error(uv_default_loop()).code, NULL); exit(-2); } // fire 'open' event client->server->on_event(client, EVT_CLI_OPEN, 0, NULL); // start reading client uv_read_start((uv_stream_t *)&client->handle, buf_alloc, client_on_read);}
开发者ID:dvv,项目名称:libuv-test,代码行数:28,
示例25: recv_cbstatic void recv_cb(uv_pipe_t* handle, ssize_t nread, const uv_buf_t* buf, uv_handle_type pending) { int r; ASSERT(pending == ctx.expected_type); ASSERT(handle == &ctx.channel); ASSERT(nread >= 0); if (pending == UV_NAMED_PIPE) r = uv_pipe_init(ctx.channel.loop, &ctx.recv.pipe, 0); else if (pending == UV_TCP) r = uv_tcp_init(ctx.channel.loop, &ctx.recv.tcp); else abort(); ASSERT(r == 0); r = uv_accept((uv_stream_t*)&ctx.channel, &ctx.recv.stream); ASSERT(r == 0); uv_close((uv_handle_t*)&ctx.channel, NULL); uv_close(&ctx.send.handle, NULL); uv_close(&ctx.recv.handle, NULL); num_recv_handles++;}
开发者ID:4T-Shirt,项目名称:node,代码行数:26,
示例26: client_accept_cbvoidclient_accept_cb(uv_stream_t *server, int status) { struct client_context *client = new_client(); struct remote_context *remote = new_remote(idle_timeout); client->remote = remote; remote->client = client; uv_timer_init(server->loop, remote->timer); uv_tcp_init(server->loop, &client->handle.tcp); uv_tcp_init(server->loop, &remote->handle.tcp); int rc = uv_accept(server, &client->handle.stream); if (rc == 0) { int namelen = sizeof client->addr; uv_tcp_getpeername(&client->handle.tcp, &client->addr, &namelen); reset_timer(remote); // start timer connect_to_remote(remote); } else { logger_log(LOG_ERR, "accept error: %s", uv_strerror(rc)); close_client(client); close_remote(remote); }}
开发者ID:road0001,项目名称:xsocks,代码行数:26,
示例27: connect_cbstatic void connect_cb(uv_stream_t* listener, int status){ int n; if (status) { SHOW_UV_ERROR(listener->loop); return; } server_ctx *ctx = calloc(1, sizeof(server_ctx)); ctx->client.data = ctx; ctx->remote.data = ctx; ctx->handshake_buffer = calloc(1, HANDSHAKE_BUFFER_SIZE); if (!ctx || !ctx->handshake_buffer) SHOW_UV_ERROR_AND_EXIT(listener->loop); n = uv_tcp_init(listener->loop, &ctx->client); if (n) SHOW_UV_ERROR_AND_EXIT(listener->loop); n = uv_accept(listener, (uv_stream_t *)(void *)&ctx->client); if (n) SHOW_UV_ERROR_AND_EXIT(listener->loop); n = uv_tcp_nodelay(&ctx->client, 1); if (n) SHOW_UV_ERROR_AND_EXIT(listener->loop); n = uv_read_start((uv_stream_t *)(void *)&ctx->client, client_handshake_alloc_cb, client_handshake_read_cb); if (n) SHOW_UV_ERROR_AND_EXIT(listener->loop);}
开发者ID:leecade,项目名称:shadowsocks-libuv,代码行数:33,
示例28: ipc_on_connectionstatic void ipc_on_connection(uv_stream_t* server, int status) { int r; uv_buf_t buf; uv_tcp_t* conn; if (!connection_accepted) { /* * Accept the connection and close it. Also let the other * side know. */ ASSERT(status == 0); ASSERT((uv_stream_t*)&tcp_server == server); conn = malloc(sizeof(*conn)); ASSERT(conn); r = uv_tcp_init(server->loop, conn); ASSERT(r == 0); r = uv_accept(server, (uv_stream_t*)conn); ASSERT(r == 0); uv_close((uv_handle_t*)conn, close_conn_cb); buf = uv_buf_init("accepted_connection/n", 20); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, NULL, conn_notify_write_cb); ASSERT(r == 0); connection_accepted = 1; }}
开发者ID:0x00A,项目名称:uvxx,代码行数:32,
示例29: cb_connectionstatic void cb_connection(uv_stream_t *stream, int status){ ws_server_t *ptr = (ws_server_t*)stream->data; ws_connect_t *pConnect = NULL; ptr->cb.cb_malloc(pConnect, ptr->cb.obj_malloc); if (NULL == pConnect) { printf("->strerror:malloc connect error,(%s,%d)/n", __FILE__, __LINE__); return; } if(0 == uv_accept((uv_stream_t *)(&ptr->server), (uv_stream_t*)(&pConnect->connect))) { pConnect->state = WS_CONNECTING; on_connect(pConnect); } else { if (NULL != ptr->cb.cb_connection) { ptr->cb.cb_connection(pConnect, ptr->cb.obj_connection, WS_ERROR_BAD); } else { printf("->strerror:accept error,(%s,%d)/n", __FILE__, __LINE__); } }}
开发者ID:k1rn1l,项目名称:websocket_by_libuv,代码行数:31,
注:本文中的uv_accept函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ uv_async_init函数代码示例 C++ uv__update_time函数代码示例 |