cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: connect failed if set socket non-blocking,why?

From: 黄志军 <hzhijun_at_huawei.com>
Date: Mon, 25 Oct 2004 18:17:59 +0800

----- Original Message -----
From: "Andy Hobbs" <andy_at_hobbs.uk.net>
To: "libcurl development" <curl-library_at_cool.haxx.se>
Sent: Monday, October 25, 2004 5:45 PM
Subject: Re: connect failed if set socket non-blocking,why?

> Hi,
>
> connect returns instantly when the socket is non-blocking, you need to
> call select() and wait for the connect to complete.
   
   connect return value is -1 ,but errno is also 0, that is the key reason puzzling me.
>
> Andy
>
>
> On Mon, 2004-10-25 at 09:57, 黄志军 wrote:
> > I link my program with static library libcurl.a and find it always
> > return CURLE_COULDNT_CONNECT.
> >
> > if i ignore function Curl_nonblock() in connect.c( curl-7.12.2), the
> > curl_easy_perform return success and works fine.
> >
> > But if set socket to non-blocking, the connect() return -1(rc = -1)
> >
> > and i got the following info: "errno in curl=0" and "errno out
> > curl=150", why?
> >
> >
> > /*../lib/connect.c*/
> > /* set socket non-blocking */
> > Curl_nonblock(sockfd, TRUE);
> >
> > rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen);
> >
> > fprintf(stderr, "errno in curl=%d\n", errno);
> >
> > if(-1 == rc) {
> > error = Curl_ourerrno();
> > fprintf(stderr, "errno in curl=%d\n", errno);
> >
> >
> > /*my multi-thread program:*/
> > curl_easy_perform(curl);
> > fprintf(stderr, "errno out curl=%d\n", errno);
> >
> --
> Andy Hobbs <andy_at_hobbs.uk.net>
>
Received on 2004-10-25