1 /* 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_BASE_SOCKETSERVER_H_ 12 #define WEBRTC_BASE_SOCKETSERVER_H_ 13 14 #include "webrtc/base/socketfactory.h" 15 16 namespace rtc { 17 18 class MessageQueue; 19 20 // Provides the ability to wait for activity on a set of sockets. The Thread 21 // class provides a nice wrapper on a socket server. 22 // 23 // The server is also a socket factory. The sockets it creates will be 24 // notified of asynchronous I/O from this server's Wait method. 25 class SocketServer : public SocketFactory { 26 public: 27 static const int kForever = -1; 28 29 // When the socket server is installed into a Thread, this function is 30 // called to allow the socket server to use the thread's message queue for 31 // any messaging that it might need to perform. SetMessageQueue(MessageQueue * queue)32 virtual void SetMessageQueue(MessageQueue* queue) {} 33 34 // Sleeps until: 35 // 1) cms milliseconds have elapsed (unless cms == kForever) 36 // 2) WakeUp() is called 37 // While sleeping, I/O is performed if process_io is true. 38 virtual bool Wait(int cms, bool process_io) = 0; 39 40 // Causes the current wait (if one is in progress) to wake up. 41 virtual void WakeUp() = 0; 42 }; 43 44 } // namespace rtc 45 46 #endif // WEBRTC_BASE_SOCKETSERVER_H_ 47