-
class
TCPSocketDataIO
: public PortableDataIO
(Return to index)
-
Data I/O to and from a TCP socket!
Type:
Superclasses:
Include file:
../../dataio/TCPSocketDataIO.h
Synopsis:
Public methods:
- public virtual void
FlushOutput ()
Flushes the output buffer by turning off Nagle's Algorithm
and then turning it back on again
- public int
GetSocket () const
Returns the socket descriptor held by this object, or
-1 if there is none.
- public status_t
PollSocketReadiness (bool & setReadyForDataRead, bool & setReadyForDataWrite) const
Sets the parameters to reflect the current state of the socket
(setReadyForDataRead) - will be set true iff there is incoming data ready to be read.
(setReadyForDataWrite) - will be set true iff there is room to send more data.
Returns B_NO_ERROR on success, B_ERROR on failure.
- public virtual ssize_t
Read (void * buffer, size_t size)
Reads bytes from the socket and places them into (buffer).
See PortableDataIO::Read() for semantics.
- public void
ReleaseSocket ()
Releases control of the contained socket to the calling code.
After this method returns, this object no longer owns or can
use the socket descriptor it once held.
- public status_t
SetBlockingIOEnabled (bool blocking)
Enables or diables blocking I/O on this socket.
If this object is to be used by an AbstractMessageIOGateway,
then non-blocking I/O is usually better to use.
- public status_t
SetNaglesAlgorithmEnabled (bool enabled)
Turns Nagle's algorithm (output packet buffering/coalescing) on or off.
- public
TCPSocketDataIO (int sockfd, bool blocking)
(sockfd) the socket to use
blockingIO says whether to use blocking socket I/O or non-blocking
socket I/O. If you will be using this object with a AbstractMessageIOGateway,
and/or select(), then it's usually better to set blocking to false.
- public virtual ssize_t
Write (const void * buffer, size_t size)
Reads bytes from (buffer) and sends them out to the TCP socket.
See PortableDataIO::Read() for semantics.
- public
~TCPSocketDataIO ()
Closes the held socket descriptor.