Okay, this might be easier - I've managed to replicate it using a TCP 
socket connection. I get the exact same output. Test code attached.

Thanks.

-Jack

On Friday, December 6, 2013 1:48:07 PM UTC-6, Jack Lund wrote:
>
> Thanks for the quick reply!
>
> On Friday, December 6, 2013 2:49:15 AM UTC-6, Saúl Ibarra Corretgé wrote:
>>
>>
>> What version of libuv did you test? I don't see how you could get 
>> EINPROGRESS in your callback, on Unix, you can only get EBADF or 0, 
>> AFAIS: 
>> https://github.com/joyent/libuv/blob/master/src/unix/poll.c#L30-L50 
>>
>
> The version I'm building against for node.js 0.10.12 is libuv 0.10.11. I 
> should probably mention that when I said I was getting
> EINPROGRESS back, I was being inaccurate - I was getting -1 back as the 
> status, and the errno was EINPROGRESS. I've since tried building
> against libuv 0.10.12, and I do indeed get EBADF back in the status 
> instead of just -1.
>  
>
>>
>> Does the libuv test suite pass for you? It contains a few uv_poll_t test 
>> cases. 
>>
>>
> It does (well, except for the TCP/IP v6 cases, but that's not a big deal). 
> I should mention that I'm running all this on a Raspberry Pi
> running the latest version of Raspbian. I'm building against BlueZ version 
> 5.7 as well.
>
> Last, do you have a small test case which reproduces this? 
>>
>>
> I do. You'll need BlueZ headers and libraries installed to make it build. 
> I've attached the C++ test file.
>
> Here's how I'm building it:
>
> $ c++ -g -fpermissive -I/home/pi/.node-gyp/0.10.12/deps/uv/include/ 
> -lbluetooth -lpthread -lrt -o test test.cc ../libuv/out/Debug/libuv.a
>
> I went ahead and built it on my pi against libuv 0.10.12,
> which gave me the following output when I ran it:
>
> $ ./test
> connect returned -1, errno = 115
> onConnect called, status = -9
>
> Thanks for your help!
>
> -Jack
>
>>
>>

-- 
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 http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/groups/opt_out.
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <uv.h>

void onConnect(uv_poll_t* handle, int status, int events) {
  printf("onConnect called, status = %d\n", status);
}

int main(int argc, const char** argv) {
  uv_loop_t *loop = uv_default_loop();

  int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock < 0)
  {
    perror("socket");
    return -1;
  }

	int r = fcntl(sock, F_GETFL);
	if (r < 0) {
    perror("fcntl");
		close(sock);
    return -1;
	}

	if (fcntl(sock, F_SETFL, r | O_NONBLOCK) < 0) {
    perror("fcntl");
		close(sock);
    return -1;
	}

	int err;
	struct sockaddr_in addr;

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = inet_addr("192.168.1.1");
  addr.sin_port = htons(80);

	err = connect(sock, (struct sockaddr *) &addr, sizeof(addr));
  printf("connect returned %d, errno = %d\n", err, errno);
	if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS))
  {
    perror("connect");
    return -1;
  }
  uv_poll_t* poll_handle = new uv_poll_t;
  uv_poll_init_socket(uv_default_loop(), poll_handle, sock);
  uv_poll_start(poll_handle, UV_WRITABLE, onConnect);

  uv_run(loop, UV_RUN_DEFAULT);
}

Reply via email to