Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CAsyncSocketBase Class Reference

Base class for all asynchronous socket io support. More...

#include <AsyncSocket.h>

Inheritance diagram for OW32::CAsyncSocketBase:

OW32::CAsyncAPCSocket OW32::CAsyncBlockingSocket OW32::CAsyncIoCompletionSocket OW32::CAsyncMessageSocket List of all members.

Public Member Functions

 CAsyncSocketBase (CAsyncSocketCallback *pCallback)
 Construct an uninitialised socket with the given callback.
 CAsyncSocketBase (CAsyncSocketCallback *pCallback, SOCKET s)
 Constructor taking ownership of an existing socket.
virtual ~CAsyncSocketBase ()
 Virtual d'tor as this is a base class.
void setCallback (CAsyncSocketCallback *pCallback)
 Set the callback for the socket.
CAsyncSocketCallbackgetCallback () const
 Get the callback for the socket.
 operator SOCKET ()
 Extractor for the encapsulated socket.
 operator HANDLE ()
 Extractor for the encapsulated socket.
SOCKET detach ()
 Detach the encapsulated socket.
void attach (SOCKET s)
 Attach a new socket.
virtual void setTimeout (DWORD timeout)
 Set the timeout for the socket.
virtual DWORD getTimeout ()
 Get the timeout for the socket.
virtual int close ()
 Close the encapsulated socket handle.
int bind (const struct sockaddr *name, int namelen)
 Bind the socket.
int bind (CSockAddrIn &sockaddr_in)
 Bind the socket to a CSockAddrIn encapsulated address.
int listen (int backlog=SOMAXCONN)
 Listen on the socket.
virtual SOCKET accept (sockaddr *addr, int *addrlen)
 Start accepting connections on the given socket.
virtual SOCKET accept (CSockAddrIn &sockaddr_in)
 Start accepting connections on the given socket.
virtual int connect (const struct sockaddr *name, int namelen)
 Connect to a remote server (stream) or set a default outgoing address for send (datagram).
virtual int connect (CSockAddrIn &sockaddr_in)
 Connect to a remote server (stream) or set a default outgoing address for send (datagram).
virtual int shutdown (int how)
 Shutdown the socket.
virtual int recv (char *buf, int len)=0
 Asynchronous recv.
virtual int send (const char *buf, int len)=0
 Asynchronous send.
virtual int sendv (WSABUF *bufs, DWORD nbufs)
 Asynchronous vector send.
virtual int transmitFile (HANDLE hFile, DWORD nNumberOfBytesToWrite, DWORD nNumberOfBytesPerSend, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, DWORD dwFlags)
 Asynchronous transmitFile.

Protected Attributes

CAsyncSocketCallbackm_pCallback
 The callback function.
SOCKET m_socket
 The socket.
DWORD m_timeout
 The timeout.

Detailed Description

Base class for all asynchronous socket io support.


Constructor & Destructor Documentation

OW32::CAsyncSocketBase::CAsyncSocketBase CAsyncSocketCallback pCallback  )  [inline]
 

Construct an uninitialised socket with the given callback.

Parameters:
pCallback The callback for notifications

OW32::CAsyncSocketBase::CAsyncSocketBase CAsyncSocketCallback pCallback,
SOCKET  s
[inline]
 

Constructor taking ownership of an existing socket.

Parameters:
pCallback The callback for notifications
s The socket to own


Member Function Documentation

virtual SOCKET OW32::CAsyncSocketBase::accept CSockAddrIn sockaddr_in  )  [inline, virtual]
 

Start accepting connections on the given socket.

Note -- does not lock -- assumes this is part of socket construction.

Parameters:
sockaddr_in The accept'd address
Returns:
The accepted socket or SOCKET_ERROR

virtual SOCKET OW32::CAsyncSocketBase::accept sockaddr *  addr,
int *  addrlen
[inline, virtual]
 

Start accepting connections on the given socket.

Note -- does not lock -- assumes this is part of socket construction.

Parameters:
addr The accept'd address
addrlen The length of the accept'd address
Returns:
The accepted socket or SOCKET_ERROR

void OW32::CAsyncSocketBase::attach SOCKET  s  )  [inline]
 

Attach a new socket.

Note: socket must be idle for this to be safe.

Parameters:
s The new socket handle

int OW32::CAsyncSocketBase::bind CSockAddrIn sockaddr_in  )  [inline]
 

Bind the socket to a CSockAddrIn encapsulated address.

Note -- does not lock -- assumes this is part of socket construction.

Parameters:
sockaddr_in The address to bind to

int OW32::CAsyncSocketBase::bind const struct sockaddr *  name,
int  namelen
[inline]
 

Bind the socket.

Note -- does not lock, assumes this is prat of socket construction.

Parameters:
name The address to bind to
namelen The length of the address

virtual int OW32::CAsyncSocketBase::connect CSockAddrIn sockaddr_in  )  [inline, virtual]
 

Connect to a remote server (stream) or set a default outgoing address for send (datagram).

Parameters:
sockaddr_in The address to bind to

Reimplemented in OW32::CAsyncBlockingSocket, OW32::CAsyncIoCompletionSocket, OW32::CAsyncAPCSocket, and OW32::CAsyncMessageSocket.

virtual int OW32::CAsyncSocketBase::connect const struct sockaddr *  name,
int  namelen
[inline, virtual]
 

Connect to a remote server (stream) or set a default outgoing address for send (datagram).

Parameters:
name The address to connect to
namelen The length of the address

Reimplemented in OW32::CAsyncBlockingSocket, OW32::CAsyncIoCompletionSocket, OW32::CAsyncAPCSocket, and OW32::CAsyncMessageSocket.

CAsyncSocketCallback* OW32::CAsyncSocketBase::getCallback  )  const [inline]
 

Get the callback for the socket.

Returns:
The callback function

virtual DWORD OW32::CAsyncSocketBase::getTimeout  )  [inline, virtual]
 

Get the timeout for the socket.

Returns:
The timeout, in ms

int OW32::CAsyncSocketBase::listen int  backlog = SOMAXCONN  )  [inline]
 

Listen on the socket.

Note -- does not lock -- assumes this is part of socket construction.

Parameters:
backlog The backlog, defaults to SOMAXCONN

virtual int OW32::CAsyncSocketBase::recv char *  buf,
int  len
[pure virtual]
 

Asynchronous recv.

onReadCompletion will be called when the read completes.

Parameters:
buf The buffer for data
len The amount of data to try to read
Returns:
SOCKET_ERROR for any errors, or 0 for success. If the function returns SOCKET_ERROR the callback will not be invoked.

Implemented in OW32::CAsyncBlockingSocket, OW32::CAsyncIoCompletionSocket, OW32::CAsyncAPCSocket, and OW32::CAsyncMessageSocket.

virtual int OW32::CAsyncSocketBase::send const char *  buf,
int  len
[pure virtual]
 

Asynchronous send.

onSendCompletion will be called when the send completes.

Parameters:
buf The buffer for data
len The amount of data to try to send
Returns:
SOCKET_ERROR for any errors, or 0 for success. If the function returns SOCKET_ERROR the callback will not be invoked.

Implemented in OW32::CAsyncBlockingSocket, OW32::CAsyncIoCompletionSocket, OW32::CAsyncAPCSocket, and OW32::CAsyncMessageSocket.

virtual int OW32::CAsyncSocketBase::sendv WSABUF *  bufs,
DWORD  nbufs
[inline, virtual]
 

Asynchronous vector send.

onSendCompletion will be called when the send completes. Not be supported for all socket types yet.

Parameters:
bufs The data buffers
nbufs The number of data buffers
Returns:
SOCKET_ERROR for any errors, or 0 for success. If the function returns SOCKET_ERROR the callback will not be invoked.

Reimplemented in OW32::CAsyncIoCompletionSocket.

void OW32::CAsyncSocketBase::setCallback CAsyncSocketCallback pCallback  )  [inline]
 

Set the callback for the socket.

Must only be used when the socket is idle.

Parameters:
pCallback The new callback function

virtual void OW32::CAsyncSocketBase::setTimeout DWORD  timeout  )  [inline, virtual]
 

Set the timeout for the socket.

Parameters:
timeout The timeout, in ms

Reimplemented in OW32::CAsyncIoCompletionSocket.

virtual int OW32::CAsyncSocketBase::shutdown int  how  )  [inline, virtual]
 

Shutdown the socket.

Parameters:
how How to shutdown (usually SD_SEND)

Reimplemented in OW32::CAsyncIoCompletionSocket.

virtual int OW32::CAsyncSocketBase::transmitFile HANDLE  hFile,
DWORD  nNumberOfBytesToWrite,
DWORD  nNumberOfBytesPerSend,
LPTRANSMIT_FILE_BUFFERS  lpTransmitBuffers,
DWORD  dwFlags
[inline, virtual]
 

Asynchronous transmitFile.

onTransmitFileCompletion will be called when the send complets. May not be supported for all socket types yet.

Parameters:
hFile The file to transmit, may be NULL.
nNumberOfBytesToWrite The number of bytes of the file to transmit
nNumberOfBytesPerSend May be 0 for a default
lpTransmitBuffers Extra head and tail data if required
dwFlags See API documentation

Reimplemented in OW32::CAsyncIoCompletionSocket.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:23 2005 for OW32 by  doxygen 1.3.9.1