Last active
August 29, 2015 13:57
-
-
Save talebook/9661735 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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