Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
SocketClient.h
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Category:
Game Server Simulator
Development Platform:
C/C++
- /********************************************************************
- created: 2003/02/18
- file base: SocketClient
- file ext: h
- author: liupeng
- purpose:
- *********************************************************************/
- #ifndef __INCLUDE_SOCKETCLIENT_H__
- #define __INCLUDE_SOCKETCLIENT_H__
- #if defined (_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #include "UsesWinsock.h"
- #include "Thread.h"
- #include "CriticalSection.h"
- #include "IOBuffer.h"
- #include "ManualResetEvent.h"
- #include "NodeList.h"
- #include "OpaqueUserData.h"
- #include "EventSelect.h"
- /*
- * namespace OnlineGameLib::Win32
- */
- namespace OnlineGameLib {
- namespace Win32 {
- class CSocketClient : protected CThread, private CUsesWinsock, private CIOBuffer::Allocator
- {
- public:
- virtual ~CSocketClient();
- using CThread::Start;
- void ConnectTo(
- const _tstring &addressToConnectServer,
- unsigned short portToConnectServer
- );
- void StartConnections();
- void StopConnections();
- void InitiateShutdown();
- void WaitForShutdownToComplete();
- void Write( const char *pData, size_t dataLength );
- protected:
- CSocketClient(
- const _tstring &addressToConnectServer,
- unsigned short portToConnectServer,
- size_t maxFreeBuffers,
- size_t bufferSize /* = 1024 */
- );
- CSocketClient(
- size_t maxFreeBuffers,
- size_t bufferSize /* = 1024 */
- );
- virtual void PreWrite(
- CIOBuffer *pBuffer,
- const char *pData,
- size_t dataLength ) {};
- void ReleaseBuffers();
- /*
- * Virtual function has different access specifier to base class
- */
- virtual int Run();
- private:
- /*
- * Override this to create the listening socket of your choice
- */
- virtual SOCKET CreateConnectionSocket(
- const _tstring &addressToConnectServer,
- unsigned short port) = 0;
- /*
- * Interface for derived classes to receive state change notifications...
- */
- virtual void OnStartConnections() {};
- virtual void OnStopConnections() {};
- virtual void OnShutdownInitiated() {};
- virtual void OnShutdownComplete() {};
- virtual void OnConnect() {};
- virtual void OnClose() {};
- void OnRead( CIOBuffer *pBuffer );
- virtual void ReadCompleted( CIOBuffer *pBuffer ) = 0;
- void OnWrite();
- virtual void OnError( const _tstring &message );
- SOCKET m_connectSocket;
- CEventSelect m_eventSelect;
- CManualResetEvent m_shutdownEvent;
- CManualResetEvent m_successConnectionsEvent;
- _tstring m_address;
- unsigned short m_port;
- };
- } // End of namespace OnlineGameLib
- } // End of namespace Win32
- #endif //__INCLUDE_SOCKETCLIENT_H__