Report a paste

Please put a quick comment for the admin.

If it looks like spam, the admin will mark it as spam so that the spam filter picks it up in the future.

If the paste contains something private or offensive, it'll probably just be deleted.

poll.d

import std.stdio;

const POLLIN = 0x001;
const POLLPRI = 0x002;
const POLLOUT = 0x004;

struct pollfd
{
  int fd;
  short events;
  short revents;
};

extern (C)
{
  int poll(pollfd* fds, ulong nfds, int timeout);
}

void main()
{
  pollfd[1] fds;

  fds[0].fd = 0;
  fds[0].events = POLLIN;

  int rv = poll(cast(pollfd*) fds, 1, 3500);
  if (rv == -1) {
    writeln("poll error");
  }
  else if (rv == 0) {
    writeln("timeout! not data.");
  }
  else {
    if (fds[0].events & POLLIN) {
      writeln("got data!");
    }
  }
}