joyent/libuv — Issue #303: Assertion failed on connection timed out
Author: bsnote
Created: 2012-02-01 08:41:17+00:00
State: open

```c
#include
#include "uv.h"

static void connect_cb(uv_connect_t* req, int status) {
if (status) {
printf("connect_cb: %s\n", uv_strerror(uv_last_error(uv_default_loop())));
}
else {
}
}

int main(int argc, char* argv[]) {
struct sockaddr_in address = uv_ip4_addr("172.158.45.34", 80);
uv_tcp_t* handle = malloc(sizeof(uv_tcp_t));
int r = uv_tcp_init(uv_default_loop(), handle);

if (r) {
printf("uv_tcp_init: %s\n", uv_strerror(uv_last_error(uv_default_loop())));
}

uv_connect_t* req = malloc(sizeof(uv_connect_t));
r = uv_tcp_connect(req, handle, address, connect_cb);

if (r) {
printf("uv_tcp_connect: %s\n", uv_strerror(uv_last_error(uv_default_loop())));
}

r = uv_run(uv_default_loop());

if (r) {
printf("uv_run: %s\n", uv_strerror(uv_last_error(uv_default_loop())));
}
}
```

when executing this program, it's aborted. Below is the output

connect_cb: connection timed out
program: src/unix/stream.c:685: uv__stream_io: Assertion `stream->type == UV_TCP || stream->type == UV_NAMED_PIPE || stream->type == UV_TTY' failed.
Aborted
bsnote@ubuntu64:~/src/program$