亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? socketserver.h

?? 這個(gè)動(dòng)態(tài)鏈接庫(kù)是Socket通過(guò)COm串口實(shí)現(xiàn)數(shù)據(jù)通信
?? H
字號(hào):
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#ifndef JETBYTE_TOOLS_WIN32_SOCKET_SERVER_INCLUDED__
#define JETBYTE_TOOLS_WIN32_SOCKET_SERVER_INCLUDED__
///////////////////////////////////////////////////////////////////////////////
//
// File           : $Workfile: SocketServer.h $
// Version        : $Revision: 20 $
// Function       : 
//
// Author         : $Author: Len $
// Date           : $Date: 7/06/02 14:13 $
//
// Notes          : 
//
// Modifications  :
//
// $Log: /Web Articles/SocketServers/SimpleProtocolServer2/JetByteTools/Win32Tools/SocketServer.h $
// 
// 20    7/06/02 14:13 Len
// Lint issues.
// 
// 19    5/06/02 19:17 Len
// Abortive socket closure is now done by an IO pool worker thread. This
// is a workaround for a problem with the COM wrapper.
// 
// 18    29/05/02 12:05 Len
// Lint issues.
// 
// 17    26/05/02 15:10 Len
// Factored out common 'user data' code into a mixin base class.
// 
// 16    24/05/02 12:13 Len
// Refactored all the linked list stuff for the sockets into a NodeList
// class.
// 
// 15    21/05/02 11:36 Len
// User data can now be stored/retrieved as either an unsigned long or a
// void *.
// A CIOBuffer containing the client's address is now passed with
// OnConnectionEstablished().
// 
// 14    21/05/02 8:33 Len
// Allow derived class to flush buffer allocator in destructor so that it
// can receive notifications about buffer release.
// 
// 13    21/05/02 8:05 Len
// SocketServer now derives from the buffer allocator.
// 
// 12    20/05/02 23:17 Len
// Updated copyright and disclaimers.
// 
// 11    20/05/02 17:26 Len
// Merged OnNewConnection() into OnConnectionEstablished(). 
// We now pass the socket to OnConnectionClosed() so that the derived
// class can dealocate any per connection user data when the connection is
// closed.
// 
// 10    20/05/02 14:45 Len
// SocketServer doesn't need to pass allocator to WorkerThread.
// 
// 9     20/05/02 14:38 Len
// WorkerThread never needs to use the allocator.
// 
// 8     20/05/02 8:09 Len
// Moved the concept of the io operation used for the io buffer into the
// socket server. The io buffer now simply presents 'user data' access
// functions. Added a similar concept of user data to the socket class so
// that users can associate their own data with a connection . Derived
// class is now notified when a connection occurs so that they can send a
// greeting or request a read, etc. 
// General code cleanup and refactoring.
// 
// 7     16/05/02 21:35 Len
// Users now signal that we're finished with a socket by calling
// Shutdown() rather than Close().
// 
// 6     14/05/02 14:37 Len
// Expose CThread::Start() using a using declaration rather than a
// forwarding function.
// Lint cleanup.
// 
// 5     14/05/02 13:53 Len
// We now explicitly start the thread pool rather than allowing it to
// start itself in the constructor. There was a race condition over the
// completion of construction of derived classes and the first access to
// the pure virtual functions.
// Refactored some of the socket code to improve encapsulation.
// 
// 4     13/05/02 13:44 Len
// Added OnError() methods so that derived class can do something about
// obscure error situations.
// Added a 'max free sockets' concept so that the socket pool can shrink
// as well as grow. This exposed a problem in how we were handling sockets
// - knowing when we can actually delete them was complicated so they're
// now reference counted.
// 
// 3     11/05/02 11:04 Len
// Made CreateListeningSocket() pure virtual as there are an infinte
// number of ways that you can create the listening socket so we'll allow
// the derived class to specify exactly how it's done.
// 
// 2     10/05/02 19:25 Len
// Lint options and code cleaning.
// 
// 1     9/05/02 18:47 Len
// 
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 1997 - 2002 JetByte Limited.
//
// JetByte Limited grants you ("Licensee") a non-exclusive, royalty free, 
// licence to use, modify and redistribute this software in source and binary 
// code form, provided that i) this copyright notice and licence appear on all 
// copies of the software; and ii) Licensee does not utilize the software in a 
// manner which is disparaging to JetByte Limited.
//
// This software is provided "as is" without a warranty of any kind. All 
// express or implied conditions, representations and warranties, including
// any implied warranty of merchantability, fitness for a particular purpose
// or non-infringement, are hereby excluded. JetByte Limited and its licensors 
// shall not be liable for any damages suffered by licensee as a result of 
// using, modifying or distributing the software or its derivatives. In no
// event will JetByte Limited be liable for any lost revenue, profit or data,
// or for direct, indirect, special, consequential, incidental or punitive
// damages, however caused and regardless of the theory of liability, arising 
// out of the use of or inability to use software, even if JetByte Limited 
// has been advised of the possibility of such damages.
//
// This software is not designed or intended for use in on-line control of 
// aircraft, air traffic, aircraft navigation or aircraft communications; or in 
// the design, construction, operation or maintenance of any nuclear 
// facility. Licensee represents and warrants that it will not use or 
// redistribute the Software for such purposes. 
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// Lint options
//
//lint -save
//
// Class member is a reference
//lint -esym(1725, CSocketServer::m_allocator)
//lint -esym(1725, Socket::m_server)
//lint -esym(1725, WorkerThread::m_allocator)
//lint -esym(1725, WorkerThread::m_iocp)
//
// Private copy constructor
//lint -esym(1704, CSocketServer::CSocketServer)
//lint -esym(1704, Socket::Socket)
//lint -esym(1704, WorkerThread::WorkerThread)
//
// No default constructor
//lint -esym(1712, CSocketServer)
//lint -esym(1712, Socket)
//lint -esym(1712, WorkerThread)
//
// Base class destructor isnt virtual
//lint -esym(1509, CUsesWinsock)
//
// Data member hides inherited member
//lint -esym(1516, Allocator::m_activeList)
//lint -esym(1516, Allocator::m_freeList)
//
///////////////////////////////////////////////////////////////////////////////

#include "UsesWinsock.h"
#include "Thread.h"
#include "CriticalSection.h"
#include "IOCompletionPort.h"
#include "IOBuffer.h"
#include "ManualResetEvent.h"
#include "NodeList.h"
#include "OpaqueUserData.h"

///////////////////////////////////////////////////////////////////////////////
// Namespace: JetByteTools::Win32
///////////////////////////////////////////////////////////////////////////////

namespace JetByteTools {
namespace Win32 {

///////////////////////////////////////////////////////////////////////////////
// CSocketServer
///////////////////////////////////////////////////////////////////////////////

class CSocketServer : 
   protected CThread, 
   private CUsesWinsock, 
   private CIOBuffer::Allocator
{
   public:

      class Socket;
      class WorkerThread;

      friend class Socket;

      virtual ~CSocketServer();

      using CThread::Start;

      void StartAcceptingConnections();
      void StopAcceptingConnections();

      void InitiateShutdown();

      void WaitForShutdownToComplete();

   protected :

      CSocketServer(
         unsigned long addressToListenOn,
         unsigned short portToListenOn,
         size_t maxFreeSockets,
         size_t maxFreeBuffers,
         size_t bufferSize = 1024,
         size_t numThreads = 0);

      void ReleaseSockets();

      void ReleaseBuffers();

      //lint -e{1768} Virtual function has different access specifier to base class
      virtual int Run();

   private :

      // Override this to create your worker thread

      virtual WorkerThread *CreateWorkerThread(
         CIOCompletionPort &iocp) = 0;

      // Override this to create the listening socket of your choice

      virtual SOCKET CreateListeningSocket(
         unsigned long address,
         unsigned short port) = 0;

      // Interface for derived classes to receive state change notifications...

      virtual void OnStartAcceptingConnections() {}
      virtual void OnStopAcceptingConnections() {}
      virtual void OnShutdownInitiated() {}
      virtual void OnShutdownComplete() {}

      virtual void OnConnectionCreated() {}

      virtual void OnConnectionEstablished(
         Socket *pSocket,
         CIOBuffer *pAddress) = 0;
      
      virtual void OnConnectionClosed(
         Socket * /*pSocket*/) {}

      virtual void OnConnectionDestroyed() {}

      virtual void OnError(
         const _tstring &message);

      virtual void OnBufferCreated() {}
      virtual void OnBufferAllocated() {}
      virtual void OnBufferReleased() {}
      virtual void OnBufferDestroyed() {}

      Socket *AllocateSocket(
         SOCKET theSocket);

      void ReleaseSocket(
         Socket *pSocket);

      void DestroySocket(
         Socket *pSocket);

      void PostAbortiveClose(
         Socket *pSocket);

      void Read(
         Socket *pSocket,
         CIOBuffer *pBuffer);

      void Write(
         Socket *pSocket,
         const char *pData,
         size_t dataLength, 
         bool thenShutdown);

      void Write(
         Socket *pSocket,
         CIOBuffer *pBuffer, 
         bool thenShutdown);

      const size_t m_numThreads;

      CCriticalSection m_listManipulationSection;

      typedef JetByteTools::TNodeList<Socket> SocketList;

      SocketList m_activeList;
      SocketList m_freeList;

      SOCKET m_listeningSocket;

      CIOCompletionPort m_iocp;

      CManualResetEvent m_shutdownEvent;

      CManualResetEvent m_acceptConnectionsEvent;

      const unsigned long m_address;
      const unsigned short m_port;

      const size_t m_maxFreeSockets;

      // No copies do not implement
      CSocketServer(const CSocketServer &rhs);
      CSocketServer &operator=(const CSocketServer &rhs);
};

///////////////////////////////////////////////////////////////////////////////
// CSocketServer::Socket
///////////////////////////////////////////////////////////////////////////////

class CSocketServer::Socket : public CNodeList::Node, public COpaqueUserData
{
   public :

      friend class CSocketServer;
      friend class CSocketServer::WorkerThread;

      void Read(
         CIOBuffer *pBuffer = 0);

      void Write(
         const char *pData, 
         size_t dataLength,
         bool thenShutdown = false);

      void Write(
         CIOBuffer *pBuffer,
         bool thenShutdown = false);

      void AddRef();
      void Release();

      void Shutdown(
         int how = SD_BOTH);

      void Close();

      void AbortiveClose();

   private :

      Socket(
         CSocketServer &server,                                 
         SOCKET socket);

      ~Socket();

      void Attach(
         SOCKET socket);

      CSocketServer &m_server;
      SOCKET m_socket;

      long m_ref;

      // No copies do not implement
      Socket(const Socket &rhs);
      Socket &operator=(const Socket &rhs);
};

///////////////////////////////////////////////////////////////////////////////
// CSocketServer::WorkerThread
///////////////////////////////////////////////////////////////////////////////

class CSocketServer::WorkerThread : public CThread
{
   public :

      virtual ~WorkerThread() {}

      void InitiateShutdown();

      void WaitForShutdownToComplete();

   protected :

      explicit WorkerThread(
         CIOCompletionPort &iocp);

      //lint -e{1768} Virtual function has different access specifier to base class
      virtual int Run();

   private :

      virtual void OnBeginProcessing() {}
      virtual void OnEndProcessing() {}

      virtual void OnError(
         const _tstring &message);

      void Read(
         Socket *pSocket,
         CIOBuffer *pBuffer) const;

      virtual void ReadCompleted(
         Socket *pSocket,
         CIOBuffer *pBuffer) = 0;

      void Write(
         Socket *pSocket,
         CIOBuffer *pBuffer) const;

      virtual void WriteCompleted(
         Socket *pSocket,
         CIOBuffer *pBuffer);

      void AbortiveClose(
         Socket *pSocket);

      CIOCompletionPort &m_iocp;

      // No copies do not implement
      WorkerThread(const WorkerThread &rhs);
      WorkerThread &operator=(const WorkerThread &rhs);
};

///////////////////////////////////////////////////////////////////////////////
// Namespace: JetByteTools::Win32
///////////////////////////////////////////////////////////////////////////////

} // End of namespace Win32
} // End of namespace JetByteTools 

///////////////////////////////////////////////////////////////////////////////
// Lint options
//
//lint -restore
//
///////////////////////////////////////////////////////////////////////////////

#endif // JETBYTE_TOOLS_WIN32_SOCKET_SERVER_INCLUDED__

///////////////////////////////////////////////////////////////////////////////
// End of file
///////////////////////////////////////////////////////////////////////////////

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本韩国欧美在线| 国产精品99久| 99re免费视频精品全部| 欧美一级专区免费大片| 亚洲精品ww久久久久久p站| 国产一区福利在线| 8v天堂国产在线一区二区| 中日韩免费视频中文字幕| 日韩高清一区二区| 色综合久久99| 国产精品欧美一区喷水| 精品中文字幕一区二区小辣椒| 在线观看一区不卡| 亚洲欧美综合色| 国内成+人亚洲+欧美+综合在线| 欧美性欧美巨大黑白大战| 国产精品久久久久久久久免费樱桃| 日本不卡不码高清免费观看| 在线亚洲高清视频| 亚洲视频一区二区免费在线观看| 久久爱www久久做| 欧美精品v国产精品v日韩精品| 亚洲欧洲日产国产综合网| 国产一区 二区 三区一级| 日韩欧美综合在线| 日韩av一区二区三区四区| 欧美日韩亚洲综合一区| 一二三四社区欧美黄| 99久久婷婷国产综合精品电影| 久久亚洲精精品中文字幕早川悠里| 免费高清不卡av| 91精品国产日韩91久久久久久| 亚洲最大的成人av| 91黄色免费版| 亚洲一区二区三区影院| 在线看日韩精品电影| 亚洲美女一区二区三区| 色欧美片视频在线观看| 亚洲乱码国产乱码精品精可以看| 成人白浆超碰人人人人| 国产精品久久毛片a| 成人午夜免费av| 国产精品毛片高清在线完整版 | 精品va天堂亚洲国产| 麻豆91在线播放免费| 日韩久久久精品| 国内精品嫩模私拍在线| 亚洲精品在线观看网站| 国产激情视频一区二区在线观看| 精品三级在线看| 国产尤物一区二区| 国产情人综合久久777777| av在线不卡免费看| 亚洲欧美日韩国产一区二区三区| 色老汉一区二区三区| 亚洲一二三区视频在线观看| 欧美日韩一区三区四区| 免费av网站大全久久| 日韩精品一区二区三区视频 | 亚洲国产中文字幕在线视频综合| 欧美午夜影院一区| 亚洲成人av电影| 欧美成人精品二区三区99精品| 麻豆国产91在线播放| 国产亚洲综合在线| 91在线观看免费视频| 亚洲国产综合91精品麻豆| 日韩一区二区三区电影 | 亚洲午夜成aⅴ人片| 91精品一区二区三区在线观看| 卡一卡二国产精品| 中文字幕欧美国产| 欧美亚洲禁片免费| 久久精工是国产品牌吗| 亚洲国产精品高清| 欧美视频一区二区在线观看| 人妖欧美一区二区| 久久亚洲一区二区三区四区| aaa亚洲精品| 日日夜夜一区二区| 精品国产乱码久久久久久影片| 成人小视频在线观看| 亚洲精品免费播放| 日韩无一区二区| 成人精品一区二区三区中文字幕| 亚洲免费电影在线| 日韩欧美的一区| av成人老司机| 久色婷婷小香蕉久久| 亚洲视频精选在线| 欧美一卡在线观看| kk眼镜猥琐国模调教系列一区二区| 亚洲一区成人在线| 国产日产亚洲精品系列| 欧美系列一区二区| 成人综合在线观看| 亚洲成年人影院| 欧美经典一区二区| 欧美精品久久99久久在免费线| 东方aⅴ免费观看久久av| 午夜精品一区二区三区电影天堂 | 久久亚洲精品小早川怜子| 色94色欧美sute亚洲线路一久| 看国产成人h片视频| 亚洲美女少妇撒尿| 久久亚洲免费视频| 欧美精品一二三四| av激情综合网| 激情图区综合网| 亚洲国产裸拍裸体视频在线观看乱了| 久久影音资源网| 在线电影一区二区三区| 99久久99久久精品国产片果冻| 日韩av中文在线观看| 亚洲精品成人天堂一二三| 久久噜噜亚洲综合| 这里是久久伊人| 色综合天天视频在线观看| 精彩视频一区二区| 日本怡春院一区二区| 一级女性全黄久久生活片免费| 国产视频视频一区| 日韩一区二区三区视频在线| 色av综合在线| 99这里都是精品| 国产美女在线观看一区| 日本不卡一区二区| 亚洲一区二区三区小说| 成人免费在线视频观看| 久久精品视频网| 6080国产精品一区二区| 欧美在线不卡视频| 91麻豆自制传媒国产之光| 国产成人a级片| 久久国产尿小便嘘嘘| 日日夜夜精品视频天天综合网| 亚洲少妇30p| 国产精品美日韩| 久久久综合九色合综国产精品| 日韩午夜电影在线观看| 制服丝袜日韩国产| 日本乱码高清不卡字幕| 不卡欧美aaaaa| 成人av综合一区| 成人小视频在线| 成人激情视频网站| 国产91对白在线观看九色| 狠狠狠色丁香婷婷综合久久五月| 午夜精品久久一牛影视| 亚洲成av人片www| 夜夜嗨av一区二区三区| 亚洲激情第一区| 亚洲免费毛片网站| 亚洲精品va在线观看| 亚洲免费av在线| 一二三四区精品视频| 亚洲综合一区在线| 一区二区成人在线观看| 亚洲午夜久久久久久久久久久| 亚洲美女视频在线观看| 亚洲制服丝袜一区| 亚洲一级二级在线| 日韩中文字幕区一区有砖一区| 亚洲二区视频在线| 日韩电影免费在线看| 美腿丝袜一区二区三区| 极品瑜伽女神91| 国产成人综合网站| 不卡一区中文字幕| 色网站国产精品| 欧美亚洲另类激情小说| 在线不卡欧美精品一区二区三区| 在线播放视频一区| 精品日韩成人av| 亚洲国产精品av| 一区二区在线免费观看| 日韩中文字幕亚洲一区二区va在线 | 欧美日韩视频在线第一区| 欧美精品自拍偷拍动漫精品| 欧美成人精品福利| 中文字幕免费不卡| 亚洲综合一区在线| 奇米影视7777精品一区二区| 国产一区二区视频在线播放| www.视频一区| 欧美三级在线播放| 日韩欧美中文字幕公布| 久久精品视频免费| 有码一区二区三区| 蜜桃av一区二区| 波多野结衣中文字幕一区| 在线视频国内自拍亚洲视频| 欧美高清激情brazzers| 8x8x8国产精品| 欧美丰满美乳xxx高潮www| 日韩精品在线一区二区| 91精品国产高清一区二区三区| 久久久久久**毛片大全| 中文字幕在线不卡| 亚洲精品一卡二卡|