Public Member Functions

CTCPSocket Class Reference

TCP data socket. More...

#include <CTCPSocket.h>

Inherits IDataSocket.

List of all members.

Public Member Functions

 CTCPSocket (CArchSocket)
virtual void bind (const CNetworkAddress &)
virtual void close ()
 Close the stream.
virtual void * getEventTarget () const
 Get event target.
virtual UInt32 read (void *buffer, UInt32 n)
 Read from stream.
virtual void write (const void *buffer, UInt32 n)
 Write to stream.
virtual void flush ()
 Flush the stream.
virtual void shutdownInput ()
 Shutdown input.
virtual void shutdownOutput ()
 Shutdown output.
virtual bool isReady () const
 Test if read() will succeed.
virtual UInt32 getSize () const
 Get bytes available to read.
virtual void connect (const CNetworkAddress &)
 Connect socket.

Detailed Description

TCP data socket.

A data socket using TCP.

Definition at line 36 of file CTCPSocket.h.


Member Function Documentation

void CTCPSocket::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.

Reimplemented from IDataSocket.

Definition at line 90 of file CTCPSocket.cpp.

References ISocket::getDisconnectedEvent().

void CTCPSocket::connect ( const CNetworkAddress  )  [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.

Implements IDataSocket.

Definition at line 256 of file CTCPSocket.cpp.

References CNetworkAddress::getAddress(), and IDataSocket::getConnectedEvent().

Referenced by CIpcClient::connect().

void CTCPSocket::flush (  )  [virtual]

Flush the stream.

Waits until all buffered data has been written to the stream.

Implements IDataSocket.

Definition at line 179 of file CTCPSocket.cpp.

References CCondVarBase::wait().

void * CTCPSocket::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.

Reimplemented from IDataSocket.

Definition at line 118 of file CTCPSocket.cpp.

Referenced by CIpcClient::connect(), and CIpcClient::disconnect().

UInt32 CTCPSocket::getSize (  )  const [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 IDataSocket.

Definition at line 249 of file CTCPSocket.cpp.

References CStreamBuffer::getSize().

bool CTCPSocket::isReady (  )  const [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 IDataSocket.

Definition at line 242 of file CTCPSocket.cpp.

References CStreamBuffer::getSize().

UInt32 CTCPSocket::read ( void *  buffer,
UInt32  n 
) [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 IDataSocket.

Definition at line 124 of file CTCPSocket.cpp.

References ISocket::getDisconnectedEvent(), CStreamBuffer::getSize(), CStreamBuffer::peek(), and CStreamBuffer::pop().

void CTCPSocket::shutdownInput (  )  [virtual]

Shutdown input.

Shutdown the input side of the stream. Any pending input data is discarded and further reads immediately return 0.

Implements IDataSocket.

Definition at line 188 of file CTCPSocket.cpp.

References synergy::IStream::getInputShutdownEvent().

void CTCPSocket::shutdownOutput (  )  [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 IDataSocket.

Definition at line 215 of file CTCPSocket.cpp.

References synergy::IStream::getOutputShutdownEvent().

void CTCPSocket::write ( const void *  buffer,
UInt32  n 
) [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 IDataSocket.

Definition at line 147 of file CTCPSocket.cpp.

References synergy::IStream::getOutputErrorEvent(), CStreamBuffer::getSize(), and CStreamBuffer::write().


The documentation for this class was generated from the following files: