Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
polling.h
Go to the documentation of this file.
1 /*
2  Copyright 2011 John Selbie
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef POLLING_H
18 #define POLLING_H
19 
20 
21 struct PollEvent
22 {
23  int fd;
24  uint32_t eventflags;
25 };
26 
27 
28 // event flags
29 const uint32_t IPOLLING_READ = 0x01 << 0;
30 const uint32_t IPOLLING_WRITE = 0x01 << 1;
31 const uint32_t IPOLLING_EDGETRIGGER = 0x01 << 2;
32 const uint32_t IPOLLING_RDHUP = 0x01 << 3;
33 const uint32_t IPOLLING_HUP = 0x01 << 4;
34 const uint32_t IPOLLING_PRI = 0x01 << 5;
35 const uint32_t IPOLLING_ERROR = 0x01 << 6;
36 
37 
38 class IPolling : public IRefCounted
39 {
40 public:
41  virtual HRESULT Initialize(size_t maxSockets) = 0;
42  virtual HRESULT Close() = 0;
43  virtual HRESULT Add(int fd, uint32_t eventflags) = 0;
44  virtual HRESULT Remove(int fd) = 0;
45  virtual HRESULT ChangeEventSet(int fd, uint32_t eventflags) = 0;
46  virtual HRESULT WaitForNextEvent(PollEvent* pPollEvent, int timeoutMilliseconds) = 0;
47 };
48 
49 
50 const uint32_t IPOLLING_TYPE_BEST = 0x01 << 0;
51 const uint32_t IPOLLING_TYPE_EPOLL = 0x01 << 1;
52 const uint32_t IPOLLING_TYPE_POLL = 0x01 << 2;
53 
54 HRESULT CreatePollingInstance(uint32_t type, size_t maxSockets, IPolling** ppPolling);
55 
56 
57 
58 #endif /* POLLING_H */
59 
const uint32_t IPOLLING_TYPE_EPOLL
Definition: polling.h:51
const uint32_t IPOLLING_PRI
Definition: polling.h:34
const uint32_t IPOLLING_RDHUP
Definition: polling.h:32
const uint32_t IPOLLING_TYPE_POLL
Definition: polling.h:52
const uint32_t IPOLLING_TYPE_BEST
Definition: polling.h:50
const uint32_t IPOLLING_ERROR
Definition: polling.h:35
uint32_t eventflags
Definition: polling.h:24
const uint32_t IPOLLING_WRITE
Definition: polling.h:30
const uint32_t IPOLLING_READ
Definition: polling.h:29
HRESULT CreatePollingInstance(uint32_t type, size_t maxSockets, IPolling **ppPolling)
Definition: polling.cpp:519
const uint32_t IPOLLING_EDGETRIGGER
Definition: polling.h:31
int32_t HRESULT
Definition: hresult.h:22
const uint32_t IPOLLING_HUP
Definition: polling.h:33
int fd
Definition: polling.h:23