]> git.tdb.fi Git - libs/core.git/blob - source/pollable.cpp
Win32 tweaks
[libs/core.git] / source / pollable.cpp
1 /*
2 This file is part of libmspframework
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
5 */
6 #ifdef WIN32
7 #include <winsock2.h>
8 #include "win32poll.h"
9 #else
10 #include <poll.h>
11 #endif
12 #include "pollable.h"
13
14 namespace Msp {
15
16 short Pollable::poll(short events, int timeout)
17 {
18 #ifdef WIN32
19         return 0;
20 #else
21         pollfd pfd={get_fd(), events, 0};
22         int result=select(&pfd, 1, timeout);
23         int result=::poll(&pfd, 1, timeout);
24         if(result<=0)
25                 return result;
26         return pfd.revents;
27 #endif
28 }
29
30 }