#include <IDataSocket.h>
Inherits ISocket, and IStream.
Inherited by CTCPSocket.
Inheritance diagram for IDataSocket:
Public Member Functions | |
virtual void | bind (const CNetworkAddress &)=0 |
Bind socket to address. | |
virtual void | close () |
Close the stream. | |
virtual void * | getEventTarget () const |
Get event target. | |
virtual UInt32 | read (void *buffer, UInt32 n)=0 |
Read from stream. | |
virtual void | write (const void *buffer, UInt32 n)=0 |
Write to stream. | |
virtual void | flush ()=0 |
Flush the stream. | |
virtual void | shutdownInput ()=0 |
Shutdown input. | |
virtual void | shutdownOutput ()=0 |
Shutdown output. | |
virtual bool | isReady () const =0 |
Test if read() will succeed. | |
virtual UInt32 | getSize () const =0 |
Get bytes available to read. | |
manipulators | |
virtual void | connect (const CNetworkAddress &)=0 |
Connect socket. | |
Static Public Member Functions | |
accessors | |
static CEvent::Type | getConnectedEvent () |
Get connected event type. | |
static CEvent::Type | getConnectionFailedEvent () |
Get connection failed event type. | |
Classes | |
class | CConnectionFailedInfo |
This interface defines the methods common to all network sockets that represent a full-duplex data stream.
Definition at line 26 of file IDataSocket.h.
virtual void IDataSocket::bind | ( | const CNetworkAddress & | ) | [pure virtual] |
Bind socket to address.
Binds the socket to a particular address.
Implements ISocket.
Implemented in CTCPSocket.
void IDataSocket::close | ( | ) | [virtual] |
Close the stream.
Closes the stream. Pending input data and buffered output data are discarded. Use flush()
before close()
to send buffered output data. Attempts to read()
after a close return 0, attempts to write()
generate output error events, and attempts to flush()
return immediately.
Implements IStream.
Reimplemented in CTCPSocket.
Definition at line 39 of file IDataSocket.cpp.
virtual void IDataSocket::connect | ( | const CNetworkAddress & | ) | [pure virtual] |
Connect socket.
Attempt to connect to a remote endpoint. This returns immediately and sends a connected event when successful or a connection failed event when it fails. The stream acts as if shutdown for input and output until the stream connects.
Implemented in CTCPSocket.
Referenced by CClient::connect().
virtual void IDataSocket::flush | ( | ) | [pure virtual] |
Flush the stream.
Waits until all buffered data has been written to the stream.
Implements IStream.
Implemented in CTCPSocket.
CEvent::Type IDataSocket::getConnectedEvent | ( | ) | [static] |
Get connected event type.
Returns the socket connected event type. A socket sends this event when a remote connection has been established.
Definition at line 25 of file IDataSocket.cpp.
References CEvent::registerTypeOnce().
Referenced by CTCPSocket::connect().
CEvent::Type IDataSocket::getConnectionFailedEvent | ( | ) | [static] |
Get connection failed event type.
Returns the socket connection failed event type. A socket sends this event when an attempt to connect to a remote port has failed. The data is a pointer to a CConnectionFailedInfo.
Definition at line 32 of file IDataSocket.cpp.
References CEvent::registerTypeOnce().
void * IDataSocket::getEventTarget | ( | ) | const [virtual] |
Get event target.
Returns the event target for events generated by this stream. It should be the source stream in a chain of stream filters.
Implements IStream.
Reimplemented in CTCPSocket.
Definition at line 46 of file IDataSocket.cpp.
virtual UInt32 IDataSocket::getSize | ( | ) | const [pure virtual] |
Get bytes available to read.
Returns a conservative estimate of the available bytes to read (i.e. a number not greater than the actual number of bytes). Some streams may not be able to determine this and will always return zero.
Implements IStream.
Implemented in CTCPSocket.
virtual bool IDataSocket::isReady | ( | ) | const [pure virtual] |
Test if read()
will succeed.
Returns true iff an immediate read()
will return data. This may or may not be the same as getSize()
> 0, depending on the stream type.
Implements IStream.
Implemented in CTCPSocket.
virtual UInt32 IDataSocket::read | ( | void * | buffer, | |
UInt32 | n | |||
) | [pure virtual] |
Read from stream.
Read up to n
bytes into buffer
, returning the number read (zero if no data is available or input is shutdown). buffer
may be NULL in which case the data is discarded.
Implements IStream.
Implemented in CTCPSocket.
virtual void IDataSocket::shutdownInput | ( | ) | [pure virtual] |
Shutdown input.
Shutdown the input side of the stream. Any pending input data is discarded and further reads immediately return 0.
Implements IStream.
Implemented in CTCPSocket.
virtual void IDataSocket::shutdownOutput | ( | ) | [pure virtual] |
Shutdown output.
Shutdown the output side of the stream. Any buffered output data is discarded and further writes generate output error events. Use flush()
before shutdownOutput()
to send buffered output data.
Implements IStream.
Implemented in CTCPSocket.
virtual void IDataSocket::write | ( | const void * | buffer, | |
UInt32 | n | |||
) | [pure virtual] |
Write to stream.
Write n
bytes from buffer
to the stream. If this can't complete immediately it will block. Data may be buffered in order to return more quickly. A output error event is generated when writing fails.
Implements IStream.
Implemented in CTCPSocket.