Class CAsyncSocket Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: Custom Code in Source After IncludesNext page: m_aDeleteTimerID    Show member index
Class Declared in:
AsyncSocket.h

'Overview' icon -- Shortcut to top of page. Overview

Copyright (c) 2000-2003 Barak Weichselbaum <barak@komodia.com> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contact info:

Site:                  http://www.komodia.com Main contact:          barak@komodia.com For custom projects, consulting, or other paid services:         sales@komodia.com

Hierarchy Chart Hierarchy Chart

'Base Classes' icon -- Shortcut to top of page. Base Classes

Protected base class virtual CSpoofBase

'Data Items' icon -- Shortcut to top of page. Data Items

Private data CSocketThreadManager::TimerID m_aDeleteTimerID Our delete timer
Private data static SocketMap m_aSocketMap Our list of sockets
Private data CSocketThreadManager::TimerID m_aTimerID Our timer
Private data BOOL m_bBlocking Are we blocking
Private data BOOL m_bClosing Are we gonna close
Private data BOOL m_bFreeze Should we freeze this thread ?
Private data static BOOL m_bInitialized Are we initialized
Private data BOOL m_bList Are we in the list
Private data static BOOL m_bShuttingDown Are we shutting down?
Private data BOOL m_bTimeout Timeout indicator
Private data static BOOL m_bWindow Do we have a window handle
Private data static HINSTANCE m_hInstance Instance of our window
Private data HWND m_hLocalWindowHandle Our window's handle
Private data unsigned int m_iMsg The last async message setting
Private data int m_iSocketID ID of our socket
Private data long m_lEvent And the event
Private data CBlockedBuffer * m_pBlockedBuffer Our blocked buffer
Private data static CGenericCriticalSection * m_pCSection Our global CS
Private data CSocketThreadManager * m_pLocalThreadManager Our local thread manager (to allow custom thread mangement)
Private data static CSocketThreadManager * m_pThreadManager Our thread manager (global)
Private data unsigned char m_ucEvents Events to disable

'Constructors' icon -- Shortcut to top of page. Constructors

Private constructor

CAsyncShutdown::CAsyncShutdown()

Private constructor

CAsyncSocket( const CAsyncSocket& rSocket )

No copy Ctor
Public constructor

CAsyncSocket()

Ctor and Dtor

'Destructors' icon -- Shortcut to top of page. Destructors

Private destructor

CAsyncShutdown::~CAsyncShutdown()

Public destructor virtual

~CAsyncSocket()

'Functions' icon -- Shortcut to top of page. Functions

Protected function void

AddSocketToList()

Add the socket to the list
Private function void

AllocateHandle()

Allocate ourself a window
Public function void

AllowBlockedBuffer( BOOL bAllow )

Enable/disable blocked buffer (for when sends has to wait)
Protected function BOOL

Block()

Just block
Private function void

CAsyncShutdown::NotifyShutdown()

Private function BOOL

CheckAsyncSocketValid() const

Check if the socket is valid
Private function void

DeAllocateHandle()

Remove from thread info
Public function virtual void

DeleteSocketFromThread()

Delete an async socket in his own thread
Public function virtual void

DeleteSocketFromThread( DWORD dwTimeToWait )

Delete an async socket in his own thread
Private function static void

DeleteTimerProc( LPVOID lpData )

Our delete proc
Public function BOOL

DisableAsync()

Disable the async notification
Public function void

DisableEvents( unsigned char ucEvents )

Disable events
Public function void

ForceReceiveEvent()

Force a receive event
Public function void

FreezeThread()

Notify that don't select this thread after socket destruction
Protected function virtual SOCKET

GetAsyncHandle() const=0

Get the socket handle
Protected function CBlockedBuffer *

GetBlockedBuffer() const

Get the blocked buffer
Private function static HINSTANCE

GetInstance()

Get the instance of our APP
Private function static CAsyncSocket *

GetSocketByID( int iSockID )

Find a socket
Protected function int

GetSocketID() const

Get the ID of the socket
Protected function static CSocketThreadManager *

GetSocketThreadManager()

Get the socket thread manager
Private function CSocketThreadManager *

GetThreadManager() const

Get our thread manager (global or local)
Protected function HWND

GetWindowHandle() const

Get the handle of the window
Protected function BOOL

HasSystemTimer() const

Do we have a system timer
Public function BOOL

HasTimeout() const

Do we have a timeout
Public function static void

Initialize()

Initialize all the handlers Can be called by user, but will be invoked automatically
Protected function int

InternalWSAAsyncSelect( unsigned int wMsg, long lEvent )

Save the last blocking status
Protected function BOOL

IsBlocking() const

Are we in blocking mode
Public function BOOL

IsClosing() const

Are we closing ?
Protected function BOOL

IsTimeout() const

Do we have a timeout
Protected function BOOL

KillSystemTimer()

Kill the system timer
Public function BOOL

KillTimer()

Disable the timeout
Protected function virtual BOOL

OnSocketAccept( int iErrorCode )=0

When a socket can accept an incoming connection
Protected function virtual BOOL

OnSocketClose( int iErrorCode )=0

When a socket was closed
Protected function virtual BOOL

OnSocketConnect( int iErrorCode )=0

When a socket got a connect event (after calling connect)
Protected function virtual void

OnSocketDelete()

Delete an async socket in his own thread Not for user to override
Protected function virtual BOOL

OnSocketOOB( int iErrorCode )=0

When an OOB data came (however uses this feature shouldn't be doing it)
Protected function virtual BOOL

OnSocketReceive( int iErrorCode )=0

When socket has data in queue
Protected function virtual BOOL

OnSocketTimeout()=0

Messaging methods
Protected function virtual BOOL

OnSocketWrite( int iErrorCode )=0

When a send failed because it would block this event signals the send can be reattempted
Private function CAsyncSocket &

operator =( const CAsyncSocket& rSocket )

No assignment operator
Public function virtual BOOL

ReAsync()

Go back to async mode
Public function virtual BOOL

ReBlock()

Transfer the socket back to blocking mode!
Private function static BOOL

RegisterWindow()

Register our window
Private function static BOOL

RemoveHandlers()

Remove the handlers
Protected function void

RemoveSocketFromList()

Remove the socket from the list
Protected function virtual BOOL

SendBlockedBuffer( const CBlockedBuffer::CBlockedData& rData )

Send data from the send buffer
Protected function virtual BOOL

SetAsync()=0

Go to async regular mode
Private function static BOOL

SetHandlers()

Create our handlers
Public function static void

SetInstance( HINSTANCE hInst )

Set the instace of our app Required for Win9X
Protected function BOOL

SetSystemTimeout( int iMS )

Set a system timer
Public function BOOL

SetTimeout( int iMs )

Create a timeout Another call to SetTimeout will reset the old timer and create a new one
Public function static void

Shutdown()

Indicate a system shutdown Can be called by user, but will be invoked automatically
Public function static void

SimpleMessageMap()

Implement a message map
Public function static void

SimpleMessageMap( DWORD dwRunTimeMS )

Implement a timed message map
Public function static void

SimpleMessageMap( LPMapProc pProc, BOOL bStopWhenTRUE, DWORD dwSleep )

Implement a message map Stop it when function has a result pProc - The proc to run bStopWhenTRUE - Stop when the proc is TRUE dwSleep - How much to sleep between idle calls
Public function static char

SimpleMessageMapKey( DWORD dwSleep )

Message map that exists when a key is pressed
Protected function virtual BOOL

SocketClosed( int iErrorCode )

Socket it closed Not for user to override
Protected function void

SocketClosing()

Close the timeout if needed
Protected function virtual BOOL

SocketConnected( int iErrorCode )

Socket is connected Not for user to override
Protected function virtual void

SocketCreated()

We have a new socket Not for user to override
Private function static LRESULT CALLBACK

SocketMessageHandler( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )

Our window proc
Protected function virtual BOOL

SocketWrite( int iErrorCode )

When we have data to write Not for user to override
Protected function virtual void

SystemTimeout()

When we have a system timeout Not for user to override
Private function static void

SystemTimerProc( LPVOID lpData )

Our proc

'Friends' icon -- Shortcut to top of page. Friends

CBlockedBuffer

'Custom Code' icon -- Shortcut to top of page. Custom Code

'Implementation Details' icon -- Shortcut to top of page. Implementation Details

File(s)
C:\dev\Komodia\AsyncSocket.cpp
C:\dev\Komodia\AsyncSocket.h
Header Includes
SocketThreadManager.h     
SpoofBase.h     
BlockedBuffer.h     
map     
Source Includes
stdafx.h     for precompiled header directive
AsyncSocket.h     
ErrorHandlerMacros.h     
OSManager.h     
GenericCriticalSection.h     
conio.h     
vector     
Owner
tcpip4
Last Modified
19/02/2003 18:08:00 PM

Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.