Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

atoms::StreamSocket Class Reference
[Networking]

#include <network.hh>

Inheritance diagram for atoms::StreamSocket:

Inheritance graph
[legend]
Collaboration diagram for atoms::StreamSocket:

Collaboration graph
[legend]
List of all members.

Detailed Description

Stream socket (TCP, UNIX).

Stream sockets are reliable, character-based, connection-based sockets. Every packet sent will be received exactly once, in order. If the connection is lost, an error will (eventually) be signalled. The boundaries of packets is unimportant; they're all combined into the stream.

There's once exception to this rule: out-of-band data. This is not yet supported.

Definition at line 357 of file network.hh.

[NOHEADER]

 StreamSocket (int _fd, int _flags)
boost::shared_ptr< StreamSocketcreate (int _fd, int _flags)

Public Types

typedef boost::function< void(boost::shared_ptr< StreamSocket >) AcceptFunction )
enum  ShutdownType { sRead = SHUT_RD, sWrite = SHUT_WR, sReadWrite = SHUT_RDWR }
enum  OpenFlags {
  oRead = O_RDONLY, oWrite = O_WRONLY, oReadWrite = O_RDWR, oCreate = O_CREAT,
  oExclusive = O_EXCL, oNoctty = O_NOCTTY, oTrunc = O_TRUNC, oAppend = O_APPEND,
  oNonBlock = O_NONBLOCK, oSync = O_SYNC, oDataSync = O_DSYNC, oReadSync = O_RSYNC
}
enum  State {
  sClosed, sCreated, sConnecting, sOpen,
  sListening
}
 All possible states. More...

enum  Type {
  tUnspecified = 0, tStream = SOCK_STREAM, tDatagram = SOCK_DGRAM, tSequentialPacket = SOCK_SEQPACKET,
  tRaw = SOCK_RAW, tReliableDatagram = SOCK_RDM
}
 The type of a socket. More...

enum  Protocol { pUnspecified = 0 }

Public Member Functions

void close ()
 Closes the stream if it is not already closed.

void listen (uint numListen=5)
 Listens for connections.

boost::shared_ptr< StreamSocketaccept (SocketAddress &a)
 Accepts a connection.

void acceptContinuously (const boost::shared_ptr< IOPoller > &p, const AcceptFunction &onAccept, const boost::function< void(const IOError &)> &onError)
 Asynchronously accepts connections.

void shutdown (ShutdownType t)
 Shuts down part of the connection.

virtual bool isOpen () const
 Returns true iff the stream is fully open.

virtual bool isClosed () const
 Returns true iff the stream is fully closed.

virtual bool isReadable () const
 Returns true iff the stream is readable.

virtual bool isWritable () const
 Returns true iff the stream is writable.

virtual bool isSeekable () const
 Returns true iff the stream is seekable.

virtual void close (bool ignoreError=false)
 Close the descriptor.

size_t read (void *buf, size_t count)
 Reads one to count bytes into buf.

size_t write (const void *buf, size_t count)
 Writes one to count bytes from buf.

State getState () const
 Gets the current state of the descriptor.

bool isBlocking () const
 Returns true iff blocking mode is set.

void setBlocking (bool newval)
 Set the blocking status.

void setCloseOnExec (bool newval)
 Sets whether or not this descriptor will be closed on Process::exec().

void pollForReadAvailability (const boost::shared_ptr< IOPoller > &poller, const boost::function< void()> &onReadAvailable, const boost::function< void(const IOError &)> &onError)
 Calls a function when read operations are likely to not block.

void pollForWriteAvailability (const boost::shared_ptr< IOPoller > &poller, const boost::function< void()> &onWriteAvailable, const boost::function< void(const IOError &)> &onError)
 Calls a function when write operations are likely to not block.

void cancelPoll (const boost::shared_ptr< IOPoller > &poller)
 Cancels a poll for read or write availability.

int getFD () const
 Returns the actual file descriptor, or -1 if the stream is closed.

virtual int detach ()
 Detaches from the file without closing.

void setTimeout (const Timespan &ts)
 Sets a timeout for read and write operations.

void setReuse (bool reuse=true)
 Allows multiple uses of the same socket address.

void getAddress (SocketAddress &a)
 Gets this socket's address.

void getPeerAddress (SocketAddress &a)
 Gets peer's address.

void bind (const SocketAddress &a)
 Binds the socket to the given address.

bool connect (const SocketAddress &s)
 Opens a connection.

void connect (const SocketAddress &s, const boost::shared_ptr< IOPoller > &poller, const boost::function< void()> &onConnect, const boost::function< void(const IOError &)> &onError)
 Opens a connection asynchronously.

bool connectAgain ()
 Checks on a connection in progress.


Static Public Member Functions

boost::shared_ptr< StreamSocketcreate (SocketAddress::Domain domain, Protocol p=pUnspecified)
 Creates a new stream socket in the given domain.

std::pair< boost::shared_ptr<
StreamSocket >, boost::shared_ptr<
StreamSocket > > 
createPair ()
 Creates a pair of indistinguishable mutually-connected stream sockets.

boost::shared_ptr< UNIXStreamopen (const char *path, OpenFlags f, mode_t mode=0666)
 Opens a stream from the filesystem.

void createFIFO (const char *path, mode_t mode)
 Creates a FIFO.

template<typename DescriptorType> boost::shared_ptr< DescriptorType > attach (int fd)
 Attaches to an open file descriptor.


Static Public Attributes

const size_t MAX_ATOMIC_SIZE = PIPE_BUF

Protected Member Functions

virtual Type getType ()
void setupFlags ()

Protected Attributes

boost::weak_ptr< IOHandlethisWeak
 A weak pointer to 'this' for source in IOError.

State state
 The state of this descriptor.

int fd
 The file descriptor (-1 if closed).

int flags
 Descriptor flags, retrieved with fcntl(fd,F_GETFL).


Private Member Functions

 StreamSocket (int fd, State state)
 StreamSocket (SocketAddress::Domain domain, Protocol p)
void tryAccept (const AcceptFunction &, const boost::function< void(const IOError &)> &)

Static Private Attributes

DebugLogger LOGGER

Friends

class Socket
 Attach needs access to our private constructors.


Member Typedef Documentation

typedef boost::function<void (boost::shared_ptr<StreamSocket>) atoms::StreamSocket::AcceptFunction)
 

Definition at line 429 of file network.hh.

Referenced by acceptContinuously(), and tryAccept().


Member Enumeration Documentation

enum atoms::UNIXStream::OpenFlags [inherited]
 

See also:
open
Enumeration values:
oRead 
oWrite 
oReadWrite 
oCreate  Create the inode if it does not exist (as a regular file).
oExclusive  Use with oCreate.

Fail if the inode already exists.

oNoctty  Do not make this the process's controlling terminal even if it does not already have one.
oTrunc  Use with oWrite or oReadWrite.

Truncate the file if it already exists.

oAppend  All writes at end of file.
oNonBlock  Pollable descriptors only.
oSync  Sync data and inode to disk after every write (availability depends on platform).
oDataSync  Sync data to disk after every write (availabily depends on platform).
oReadSync  ??? (availability depends on platform)

Definition at line 273 of file unixio.hh.

enum atoms::Socket::Protocol [inherited]
 

Enumeration values:
pUnspecified 

Definition at line 173 of file network.hh.

enum atoms::StreamSocket::ShutdownType
 

Enumeration values:
sRead 
sWrite 
sReadWrite 

Definition at line 439 of file network.hh.

enum atoms::UNIXDescriptor::State [inherited]
 

All possible states.

Enumeration values:
sClosed  Closed.
sCreated  Created. For sockets only.
sConnecting  Connecting. For stream sockets only.
sOpen  Open.

Normal state for most descriptors. Not for datagram/raw sockets.

sListening  Listening. For stream sockets only.

Definition at line 41 of file unixio.hh.

Referenced by atoms::UNIXDescriptor::getState().

enum atoms::Socket::Type [inherited]
 

The type of a socket.

Bad values are below zero; good values above zero.

Enumeration values:
tUnspecified 
tStream 
tDatagram 
tSequentialPacket 
tRaw 
tReliableDatagram 

Definition at line 164 of file network.hh.


Constructor & Destructor Documentation

atoms::StreamSocket::StreamSocket int  fd,
State  state
[inline, private]
 

Definition at line 364 of file network.hh.

References atoms::UNIXDescriptor::setupFlags().

Referenced by create().

Here is the call graph for this function:

atoms::StreamSocket::StreamSocket int  _fd,
int  _flags
[inline, private]
 

For internal use only.

Definition at line 375 of file network.hh.

atoms::StreamSocket::StreamSocket SocketAddress::Domain  domain,
Protocol  p
[inline, private]
 

Definition at line 388 of file network.hh.


Member Function Documentation

shared_ptr< StreamSocket > atoms::StreamSocket::accept SocketAddress a  ) 
 

Accepts a connection.

The blocking status of the new socket will be inherited from this one. It is otherwise as the operating system creates it.

Parameters:
a Will become the address of the peer.
Returns:
The new connection.
Exceptions:
IOBlockError If non-blocking IO is selected and no connection is pending.

Definition at line 244 of file network.cc.

References create(), atoms::SocketAddress::getAddr(), atoms::SocketAddress::getAllocatedSize(), atoms::UNIXDescriptor::isBlocking(), listen(), atoms::DebugLogger::log(), and LOGGER.

Referenced by tryAccept().

Here is the call graph for this function:

void atoms::StreamSocket::acceptContinuously const boost::shared_ptr< IOPoller > &  p,
const AcceptFunction onAccept,
const boost::function< void(const IOError &)> &  onError
 

Asynchronously accepts connections.

See also:
accept(SocketAddress&)

Definition at line 374 of file network.cc.

References AcceptFunction, listen(), and atoms::UNIXDescriptor::pollForReadAvailability().

Here is the call graph for this function:

template<class DescriptorType>
boost::shared_ptr< DescriptorType > atoms::UNIXDescriptor::attach int  fd  )  [static, inherited]
 

Attaches to an open file descriptor.

Note:
This function makes up to six system calls to determine what kind of a descriptor you've given it and what state it's in. If this overhead turns out to be too high, I'll consider an API with more direct control.
Implementation:
Learns the kind of descriptor through a process like this:
attach.png
Then uses a fcntl(GETFL) system call to learn the flags.
Returns:
A subclass of UNIXDescriptor that matches the capabilities of the given descriptor.
Exceptions:
AttachError if the descriptor is not of the given type.

Definition at line 420 of file unixio.hh.

References atoms::UNIXDescriptor::attachInt().

Here is the call graph for this function:

void atoms::Socket::bind const SocketAddress a  )  [inherited]
 

Binds the socket to the given address.

Definition at line 199 of file network.cc.

References atoms::SocketAddress::getAddr(), atoms::SocketAddress::getUsedSize(), atoms::DebugLogger::log(), atoms::DebugLogger::logFatal(), and atoms::Socket::LOGGER.

Here is the call graph for this function:

void atoms::UNIXDescriptor::cancelPoll const boost::shared_ptr< IOPoller > &  poller  )  [inherited]
 

Cancels a poll for read or write availability.

Definition at line 175 of file unixio.cc.

References atoms::UNIXDescriptor::fd, atoms::DebugLogger::log(), atoms::UNIXDescriptor::LOGGER, atoms::UNIXDescriptor::pollers, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

Referenced by atoms::BufferedStreamFilter::tryFlush().

Here is the call graph for this function:

void atoms::UNIXDescriptor::close bool  ignoreError = false  )  [virtual, inherited]
 

Close the descriptor.

Note:
This operation may block on sockets, even when non-blocking IO is selected. It is guaranteed to not block if the write end has been shut down and a read has returned 0 (indicating that the remote end has done the same). Alternatively, you can disable

This is not a signal point, as it would be impossible to safely see if the socket has been closed or not on signal delivery. If you care about timely signal delivery, ensure the operation will not block in one of the two ways above.

Exceptions:
IOError if an I/O error occurs. (Possible cached from a previous operation buffered in the kernel.) The socket will remain open.

Todo:
Did it actually close here?

Definition at line 41 of file unixio.cc.

References atoms::UNIXDescriptor::disassociateFromPollers(), atoms::UNIXDescriptor::fd, atoms::DebugLogger::log(), atoms::DebugLogger::logFatal(), atoms::UNIXDescriptor::LOGGER, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

Referenced by atoms::UNIXDescriptor::~UNIXDescriptor().

Here is the call graph for this function:

void atoms::StreamSocket::close  )  [inline, virtual]
 

Closes the stream if it is not already closed.

Reimplemented from atoms::UNIXStream.

Definition at line 392 of file network.hh.

void atoms::Socket::connect const SocketAddress s,
const boost::shared_ptr< IOPoller > &  poller,
const boost::function< void()> &  onConnect,
const boost::function< void(const IOError &)> &  onError
[inherited]
 

Opens a connection asynchronously.

This functions like connect(const SocketAddress&) but automatically handles the connectAgain() and passes success or failure to a callback.

Precondition:
The stream is set to non-blocking
See also:
connect(const SocketAddress&)

Definition at line 320 of file network.cc.

References atoms::Socket::connect(), atoms::DebugLogger::log(), atoms::Socket::LOGGER, and atoms::UNIXDescriptor::pollForWriteAvailability().

Here is the call graph for this function:

bool atoms::Socket::connect const SocketAddress s  )  [inherited]
 

Opens a connection.

For a stream socket, a connection will be negotiated. For datagram or raw sockets, this merely restricts what can be received and sets the default destination.

Returns:
True if the open succeeded, false if connectAgain() will have to be called. The return is guaranteed to be true if blocking mode is selected.

Definition at line 270 of file network.cc.

References atoms::Socket::connectError(), atoms::SocketAddress::getAddr(), and atoms::SocketAddress::getUsedSize().

Referenced by atoms::Socket::connect().

Here is the call graph for this function:

bool atoms::Socket::connectAgain  )  [inherited]
 

Checks on a connection in progress.

Exceptions:
CallerLogicError if no connection is in progress.
Returns:
Same as connect.

Todo:
Test this! Might have to try getsockopt() and then read() as in attach. or maybe if we wait for a poll to return read availability, we're good.

Definition at line 283 of file network.cc.

References atoms::Socket::connectError().

Referenced by atoms::Socket::tryConnect().

Here is the call graph for this function:

boost::shared_ptr<StreamSocket> atoms::StreamSocket::create SocketAddress::Domain  domain,
Protocol  p = pUnspecified
[inline, static]
 

Creates a new stream socket in the given domain.

Definition at line 395 of file network.hh.

References StreamSocket().

Here is the call graph for this function:

boost::shared_ptr<StreamSocket> atoms::StreamSocket::create int  _fd,
int  _flags
[inline, static, private]
 

For internal use only.

Reimplemented from atoms::UNIXStream.

Definition at line 381 of file network.hh.

References StreamSocket().

Referenced by accept(), and createPair().

Here is the call graph for this function:

void atoms::UNIXStream::createFIFO const char *  path,
mode_t  mode
[static, inherited]
 

Creates a FIFO.

Use UNIXStream::open to actually open it.

Parameters:
path The name of the FIFO in the filesystem.
mode The mode that will be ANDed with the current umask to produce the permissions of the FIFO.

pair< shared_ptr< StreamSocket >, shared_ptr< StreamSocket > > atoms::StreamSocket::createPair  )  [static]
 

Creates a pair of indistinguishable mutually-connected stream sockets.

The sockets will be in the dUnix domain, which is most broadly supported.

Definition at line 363 of file network.cc.

References create(), atoms::DebugLogger::log(), atoms::DebugLogger::logFatal(), LOGGER, and std::make_pair().

Here is the call graph for this function:

int atoms::UNIXDescriptor::detach  )  [virtual, inherited]
 

Detaches from the file without closing.

Precondition:
The stream is not closed
Returns:
The file descriptor

Definition at line 65 of file unixio.cc.

References atoms::UNIXDescriptor::disassociateFromPollers(), atoms::UNIXDescriptor::fd, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

Here is the call graph for this function:

void atoms::Socket::getAddress SocketAddress a  )  [inherited]
 

Gets this socket's address.

Definition at line 169 of file network.cc.

References atoms::SocketAddress::getAddr(), atoms::SocketAddress::getAllocatedSize(), atoms::DebugLogger::logFatal(), and atoms::Socket::LOGGER.

Here is the call graph for this function:

int atoms::UNIXDescriptor::getFD  )  const [inherited]
 

Returns the actual file descriptor, or -1 if the stream is closed.

Use this with caution. UNIXDescriptor doesn't like to share the descriptor with the other chidlren.

Async signal safety:
yes, assuming the descriptor is not currently changing.

Definition at line 183 of file unixio.cc.

References atoms::UNIXDescriptor::fd, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

void atoms::Socket::getPeerAddress SocketAddress a  )  [inherited]
 

Gets peer's address.

Precondition:
Connected (sOpened state).

State atoms::UNIXDescriptor::getState  )  const [inline, inherited]
 

Gets the current state of the descriptor.

Definition at line 103 of file unixio.hh.

References atoms::UNIXDescriptor::state, and atoms::UNIXDescriptor::State.

virtual Type atoms::StreamSocket::getType void   )  [inline, protected, virtual]
 

Definition at line 457 of file network.hh.

bool atoms::UNIXDescriptor::isBlocking  )  const [inherited]
 

Returns true iff blocking mode is set.

Warning:
This is not a per-descriptor status, it is per underlying object.
Precondition:
The descriptor is not closed.

Definition at line 103 of file unixio.cc.

References atoms::UNIXDescriptor::flags, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

Referenced by accept(), atoms::UNIXStream::read(), and atoms::UNIXStream::write().

virtual bool atoms::UNIXStream::isClosed  )  const [inline, virtual, inherited]
 

Returns true iff the stream is fully closed.

Streams may be an intermediate state. For example, stream sockets can be in a 'connecting' state.

See also:
isOpen

Implements atoms::Stream.

Definition at line 310 of file unixio.hh.

virtual bool atoms::UNIXStream::isOpen  )  const [inline, virtual, inherited]
 

Returns true iff the stream is fully open.

Streams may be an intermediate state. For example, stream sockets can be in a 'connecting' state.

See also:
isClosed

Implements atoms::Stream.

Definition at line 309 of file unixio.hh.

bool atoms::UNIXStream::isReadable  )  const [virtual, inherited]
 

Returns true iff the stream is readable.

Precondition:
The stream is fully open.

Implements atoms::Stream.

Definition at line 196 of file unixio.cc.

Referenced by atoms::UNIXStream::read().

virtual bool atoms::UNIXStream::isSeekable  )  const [inline, virtual, inherited]
 

Returns true iff the stream is seekable.

Precondition:
The stream is fully open.

Implements atoms::Stream.

Reimplemented in atoms::SeekableUNIXStream.

Definition at line 313 of file unixio.hh.

bool atoms::UNIXStream::isWritable  )  const [virtual, inherited]
 

Returns true iff the stream is writable.

Precondition:
The stream is fully open.

Implements atoms::Stream.

Definition at line 203 of file unixio.cc.

Referenced by atoms::UNIXStream::write().

void atoms::StreamSocket::listen uint  numListen = 5  ) 
 

Listens for connections.

Parameters:
numListen The size of the listen queue.

Definition at line 237 of file network.cc.

Referenced by accept(), and acceptContinuously().

shared_ptr< UNIXStream > atoms::UNIXStream::open const char *  path,
OpenFlags  f,
mode_t  mode = 0666
[static, inherited]
 

Opens a stream from the filesystem.

Todo:
Error handling

Definition at line 292 of file unixio.cc.

References atoms::DebugLogger::logFatal(), and atoms::UNIXStream::LOGGER.

Here is the call graph for this function:

void atoms::UNIXDescriptor::pollForReadAvailability const boost::shared_ptr< IOPoller > &  poller,
const boost::function< void()> &  onReadAvailable,
const boost::function< void(const IOError &)> &  onError
[inline, inherited]
 

Calls a function when read operations are likely to not block.

"Read operations" includes indicating end of stream and, for listening stream sockets, accepting new connections. It will call the function when reads are likely to succeed. If the function throws an IOBlockError, it will be called again.

Definition at line 135 of file unixio.hh.

References atoms::UNIXDescriptor::pollForAvailability().

Referenced by acceptContinuously(), and atoms::BufferedStreamFilter::pollForReadAvailability2().

Here is the call graph for this function:

void atoms::UNIXDescriptor::pollForWriteAvailability const boost::shared_ptr< IOPoller > &  poller,
const boost::function< void()> &  onWriteAvailable,
const boost::function< void(const IOError &)> &  onError
[inline, inherited]
 

Calls a function when write operations are likely to not block.

It will call the function when writes are likely to succeed. If the function throws an IOBlockError, it will be called again.

Definition at line 147 of file unixio.hh.

References atoms::UNIXDescriptor::pollForAvailability().

Referenced by atoms::Socket::connect(), and atoms::BufferedStreamFilter::tryFlush().

Here is the call graph for this function:

size_t atoms::UNIXStream::read void buf,
size_t  count
[virtual, inherited]
 

Reads one to count bytes into buf.

Exceptions:
IOBlockError If non-blocking I/O has been specified and the read would block. (Pollable descriptors only)
StreamEndError For sockets or pipes, when the local read end/peer's write end has been shut down (permanent, though writing may succeed). For FIFOs, when no writers are available (temporary). For terminals, when the EOF char is hit (temporary). For block or character devices, when the end is reached (temporary).
IOError 
ConnectionResetError if the connection has been reset (StreamSocket only)
Returns:
The number of bytes read, 1 to count, inclusive.
See also:
Stream::read

Implements atoms::Stream.

Definition at line 209 of file unixio.cc.

References std::count(), atoms::UNIXDescriptor::isBlocking(), atoms::UNIXStream::isReadable(), atoms::DebugLogger::log(), atoms::UNIXStream::LOGGER, and atoms::UNIXStream::rwError().

Here is the call graph for this function:

void atoms::UNIXDescriptor::setBlocking bool  newval  )  [inherited]
 

Set the blocking status.

Warning:
This is not a per-descriptor status, it is per underlying object.
Precondition:
The descriptor is not closed.

Definition at line 108 of file unixio.cc.

References atoms::UNIXDescriptor::fd, atoms::UNIXDescriptor::flags, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

void atoms::UNIXDescriptor::setCloseOnExec bool  newval  )  [inherited]
 

Sets whether or not this descriptor will be closed on Process::exec().

This is a per-descriptor status (not per underlying object.)

Precondition:
The descriptor is not closed.

Definition at line 119 of file unixio.cc.

References atoms::UNIXDescriptor::fd, atoms::DebugLogger::logFatal(), atoms::UNIXDescriptor::LOGGER, atoms::UNIXDescriptor::sClosed, and atoms::UNIXDescriptor::state.

Here is the call graph for this function:

void atoms::Socket::setReuse bool  reuse = true  )  [inherited]
 

Allows multiple uses of the same socket address.

Sets the SO_REUSEADDR socket option.

Definition at line 229 of file network.cc.

void atoms::Socket::setTimeout const Timespan ts  )  [inherited]
 

Sets a timeout for read and write operations.

This is used in servers to prune inactive connections. It provides the same concept with two different implementations:

  • With blocking I/O (as set by setBlocking(true), it returns an IOBlockError after the timeout expires. (Internally, it uses setsockopt(..., SO_SNDTIMEO, ...) and setsockopt(..., SO_RCVTIMEO, ...).)
  • With non-blocking I/O (as set by setBlocking(false), pollForReadAvailability and pollForWriteAvailability will call the error timeout with an IOBlockError after the timeout expires. (Internally, it adds a timer to the polling list.)
    Parameters:
    ts The new timespan to set. Timespan::INFINITY will wait forever.
    Precondition:
    ts != 0. This would make little sense; maybe you mean to use non-blocking IO? That is orthogonal.

Definition at line 75 of file network.cc.

References atoms::DebugLogger::logFatal(), atoms::Socket::LOGGER, and NULL.

Here is the call graph for this function:

void atoms::UNIXDescriptor::setupFlags  )  [protected, inherited]
 

Definition at line 97 of file unixio.cc.

References atoms::UNIXDescriptor::fd, and atoms::UNIXDescriptor::flags.

Referenced by atoms::Socket::Socket(), StreamSocket(), and atoms::UNIXDescriptor::UNIXDescriptor().

void atoms::StreamSocket::shutdown ShutdownType  t  ) 
 

Shuts down part of the connection.

It's recommended for servers to shut down the write half of the connection and wait for the other end to close its write half. See the note at close.

All subsequent operations of this type will fail with a StreamEndError.

Precondition:
The connection is open

Definition at line 404 of file network.cc.

References atoms::DebugLogger::logFatal(), and LOGGER.

Here is the call graph for this function:

void atoms::StreamSocket::tryAccept const AcceptFunction ,
const boost::function< void(const IOError &)> & 
[private]
 

Definition at line 385 of file network.cc.

References accept(), and AcceptFunction.

Here is the call graph for this function:

size_t atoms::UNIXStream::write const void buf,
size_t  count
[virtual, inherited]
 

Writes one to count bytes from buf.

Exceptions:
IOBlockError If non-blocking I/O has been specified and the read would block. (Pollable descriptors only)
IOError 
StreamEndError If this is a pipe or stream socket and the local write end/peer's read end has been shut down.
NetworkUnreachableError (sockets only)
NetworkDownError (sockets only)
See also:
Stream::write

Implements atoms::Stream.

Definition at line 233 of file unixio.cc.

References std::count(), atoms::UNIXDescriptor::isBlocking(), atoms::UNIXStream::isWritable(), atoms::DebugLogger::log(), atoms::UNIXStream::LOGGER, and atoms::UNIXStream::rwError().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Socket [friend]
 

Attach needs access to our private constructors.

Definition at line 359 of file network.hh.


Member Data Documentation

int atoms::UNIXDescriptor::fd [protected, inherited]
 

The file descriptor (-1 if closed).

Definition at line 180 of file unixio.hh.

Referenced by atoms::UNIXDescriptor::availabilityCallback(), atoms::UNIXDescriptor::cancelPoll(), atoms::UNIXDescriptor::close(), atoms::UNIXDescriptor::detach(), atoms::UNIXDescriptor::disassociateFromPollers(), atoms::UNIXDescriptor::getFD(), atoms::UNIXDescriptor::pollForAvailability(), atoms::UNIXDescriptor::setBlocking(), atoms::UNIXDescriptor::setCloseOnExec(), atoms::UNIXDescriptor::setupFlags(), and atoms::UNIXDescriptor::UNIXDescriptor().

int atoms::UNIXDescriptor::flags [protected, inherited]
 

Descriptor flags, retrieved with fcntl(fd,F_GETFL).

Definition at line 183 of file unixio.hh.

Referenced by atoms::UNIXDescriptor::isBlocking(), atoms::UNIXDescriptor::setBlocking(), and atoms::UNIXDescriptor::setupFlags().

DebugLogger atoms::StreamSocket::LOGGER [static, private]
 

Reimplemented from atoms::Socket.

Referenced by accept(), createPair(), and shutdown().

const size_t atoms::UNIXStream::MAX_ATOMIC_SIZE = PIPE_BUF [static, inherited]
 

Definition at line 35 of file unixio.cc.

State atoms::UNIXDescriptor::state [protected, inherited]
 

The state of this descriptor.

Definition at line 177 of file unixio.hh.

Referenced by atoms::UNIXDescriptor::cancelPoll(), atoms::UNIXDescriptor::close(), atoms::UNIXDescriptor::detach(), atoms::UNIXDescriptor::disassociateFromPollers(), atoms::UNIXDescriptor::getFD(), atoms::UNIXDescriptor::getState(), atoms::UNIXDescriptor::isBlocking(), atoms::UNIXDescriptor::pollForAvailability(), atoms::UNIXDescriptor::setBlocking(), atoms::UNIXDescriptor::setCloseOnExec(), atoms::UNIXDescriptor::UNIXDescriptor(), and atoms::UNIXDescriptor::~UNIXDescriptor().

boost::weak_ptr<IOHandle> atoms::IOHandle::thisWeak [protected, inherited]
 

A weak pointer to 'this' for source in IOError.

Definition at line 175 of file gen.hh.


The documentation for this class was generated from the following files:
Generated on Wed Jun 15 01:21:10 2005 for atoms++ by doxygen 1.3.5