> On Jul 5, 2017, at 05:50, 何霖 <[email protected]> wrote:
> 
> void tcp_new_connection(uv_stream_t* server, int status)
> {
>     if (status)
>     {
>         fprintf(stderr, "tcp_connection_cb error![%s:%s]\n", 
> uv_err_name(status), uv_strerror(status));
>         return;
>     }
> 
>     uv_tcp_t* client = (uv_tcp_t*)malloc(sizeof(uv_tcp_t));
>     if (NULL == client)
>     {
>         // !!!!!!!!!!!!!!!!!!!!! HERE !!!!!!!!!!!!!!!!!!!!!
>         // If status is 0, it means that the client has already connected to 
> the server on Windows platform.
>         // I just want close the established socket on server.
>         // Please tell me what should I do? Or do nothing like this?
>         fprintf(stderr, "malloc(uv_tcp_t) error!\n");
>         return;
>     }

Yes, this is correct, there nothing else you can do if malloc fails.

> 
>     int error_code = uv_tcp_init(server->loop, client);
>     if (error_code)
>     {
>         // Here?
>         fprintf(stderr, "uv_tcp_init error![%s:%s]\n", uv_err_name(status), 
> uv_strerror(status));
>         return;
>     }
> 
>     error_code = uv_accept(server, (uv_stream_t*)client);
>     if (error_code)
>     {
>         uv_close((uv_handle_t*)client, &tcp_connection_on_close);
>         fprintf(stderr, "uv_accept error![%s:%s]\n", uv_err_name(status), 
> uv_strerror(status));
>         return;
>     }
> 
>     // body
>     // ...
> }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "libuv" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/libuv.
> For more options, visit https://groups.google.com/d/optout.

--
Saúl

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to