⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcplistenersocket.h

📁 跨操作系统的微型中间件
💻 H
字号:
/*    File:       TCPListenerSocket.h    Contains:   A TCP listener socket. When a new connection comes in, the listener                attempts to assign the new connection to a socket object and a Task                object. Derived classes must implement a method of getting new                Task & socket objects                        */#ifndef __TCPLISTENERSOCKET_H__#define __TCPLISTENERSOCKET_H__#include "TCPSocket.h"//创建一个监听SOCKETclass TCPListenerSocket : public TCPSocket{    public:        TCPListenerSocket() : fAddr(0), fPort(0), fOutOfDescriptors(false) {}        virtual ~TCPListenerSocket() {}                                                //addr = listening address. port = listening port. Automatically        //starts listening        OS_Error        Initialize(UInt32 addr, UInt16 port);        //You can query the listener to see if it is failing to accept        //connections because the OS is out of descriptors.        Bool			IsOutOfDescriptors() { return fOutOfDescriptors; }               private:            enum        {            kTimeBetweenAcceptsInMsec = 1000,   //UInt32            kListenQueueLength = 128            //UInt32        };        OS_Error		Listen(UInt32 queueLength);        UInt32          fAddr;        UInt16          fPort;                Bool          fOutOfDescriptors;};#endif // __TCPLISTENERSOCKET_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -