I found some strange behaviour using async_connect when connecting to
unbound ports on localhost. The callback is never called. Try
something like this:
void cb(mixed ... args) {
write("cb: %O\n", args);
}
int main () {
object o = Stdio.File();
o->async_connect("127.3.3.5", 3245, cb);
return -1;
}
A reason I found for that (not sure if there are more issues, it fixes
this problem though) is that
1) in __stdio_close_callback() read(0,1) is used to check if data can
be read from the socket instead of peek().
2) file_peek() does not check for POLLERR or POLLHUP and therefore
returns true even if the socket has been closed or some error occured
using peek() instead of read(0,1) in __stdio_close_callback() and
adding
}else if (fds.revents & (POLLERR | POLLHUP)){
ret=0;
to file_peek() fixed this issue for me.
The same problem may occur when using select() in file_peek(), I did
not test that though.
arne