tcplistenersocket.h

来自「跨操作系统的微型中间件」· C头文件 代码 · 共 55 行

H
55
字号
/*    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 + =
减小字号Ctrl + -
显示快捷键?