I've found that pth_poll()'ing socket file descriptors connected to
closed  ports, open ports, timed out ports, any type of socket I/O in
general will always give pollfd.revents = POLLIN|POLLOUT. Is this supposed
to be, should this happen? How can I work around it or get a decent
behaviour? Is there anywhere I could find an example?

this is an example, which doesnt seem to do what it should

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <pth.h>

int main(int argc, char **argv)
{

  int sockfd;
  struct sockaddr_in serv;
  pth_event_t ev_sock;
  struct pollfd p0le[1];

  sockfd = socket(AF_INET, SOCK_STREAM, 0);

  serv.sin_port = htons(23);
  serv.sin_addr.s_addr = inet_addr("127.0.0.1");
  serv.sin_family = AF_INET;
  bzero(&(serv.sin_zero), 8);

  // pth_fdmode(sockfd, PTH_FDMODE_NONBLOCK);
  if (pth_connect(sockfd, (struct sockaddr *)&serv, sizeof (struct
sockaddr)) =
    printf("FUCK IT TWICE and...\n");

  ev_sock =
pth_event(PTH_EVENT_FD|PTH_UNTIL_FD_READABLE|PTH_UNTIL_FD_WRITEABLE
  pth_wait(ev_sock);

  if (pth_event_occurred(ev_sock))
  puts("Who's the mother fucker, huh");

  /*
  p0le[0].fd = sockfd;
  p0le[0].events = POLLIN|POLLOUT;
  pth_poll(p0le, 1, 1000);
  if (p0le[0].revents)
  {
    printf("fuck a g00se\n");
    printf("[%d]\n", p0le[0].revents);
  }
  */
}

______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to