Skip to content

Instantly share code, notes, and snippets.

@talebook
Last active August 29, 2015 13:57
Show Gist options
  • Save talebook/9661735 to your computer and use it in GitHub Desktop.
Save talebook/9661735 to your computer and use it in GitHub Desktop.
int connection_refused()
{
int sockfd = async_net("127.0.0.1", 11111);
struct pollfd pfd;
pfd.fd = sockfd;
pfd.events = POLLIN|POLLOUT;
int ready = poll(&pfd, 1, -1);
printf("ready=%d, POLLIN=%d, POLLOUT=%d, POLLERR=%d\n",
ready,
( pfd.revents&POLLIN ) != 0,
( pfd.revents&POLLOUT ) != 0,
( pfd.revents&POLLERR ) != 0);
int error;
socklen_t errlen = sizeof(error);
getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &errlen);
printf("error=%d, msg=%s\n", error, strerror(error) );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment