c - Issue if polled on listening socket instead of binding fd -
in tcp server/client, polling on binding fd (fd received during socket connection , binded ip). wondering impact if polling on listening socket (socket fd received during accept call)? polling on listening socket can anyway have issue related close_wait state socket issue? sample code below:-
struct pollfd pfd; pfd.fd = sockfd; /*listening socket fd got during accept call*/ pfd.events = pollin; ret = poll(&pfd, 1, 60000); if (ret == 0 || errno == eintr) { *err = socket_err_read_timeout; *size = 0; return socket_failure; }else if (ret < 0) { close(sockfd); return socket_failure; } ret = recv(sockfd, content, *size , 0); if (ret == -1) { close(sockfd); *size = 0; return socket_failure; } else if (ret == 0) { close(sockfd); *size = 0; return socket_failure; } *size = ret; return socket_success;
Comments
Post a Comment