#include <CeylanMultiplexedServerStreamSocket.h>
Classes | |
class | MultiplexedServerStreamSocketException |
Mother class for all stream socket-related exceptions, on the multiplexed server side. More... | |
class | NetworkServerShutdownException |
Exception to be raised whenever the underlyng network server is requested to shutdown. More... | |
Public Types | |
enum | TextOutputFormat { rawText, html } |
Defines what text output formats for TextDisplayable instances are available. More... | |
Public Member Functions | |
MultiplexedServerStreamSocket (Port listeningPort, bool reuse=true) | |
Constructs a new multiplexed non-blocking server-side socket. | |
virtual | ~MultiplexedServerStreamSocket () throw () |
Virtual destructor. | |
virtual bool | isConnected () const |
Tells whether this socket is currently connected to a client. | |
virtual void | run () |
Activates this server so that it can handle incoming requests in parallel. | |
virtual AnonymousStreamSocket * | accept () |
Accepts all incoming connections, as long as it is not requested to stop. | |
virtual bool | handleConnection (AnonymousStreamSocket &connection)=0 |
Manages a connection for which data is available. | |
virtual void | closeConnection (AnonymousStreamSocket &connection) |
Closes specified connection. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns a user-friendly description of the state of this object. | |
virtual Port | getLocalPort () const |
Returns the local port number of the socket. | |
virtual ConnectionCount | getMaximumPendingConnectionsCount () const |
Returns the current maximum number of pending connections for this socket. | |
virtual void | setMaximumPendingConnectionsCount (ConnectionCount newMax) |
Sets the current maximum number of pending connections for this socket. | |
virtual void | setBlocking (bool newStatus) |
Sets the blocking mode of this stream socket. | |
virtual bool | hasAvailableData () const |
Tells whether there is data available on input, i.e. | |
virtual System::Size | read (char *buffer, System::Size maxLength) |
Reads up to maxLength bytes from this socket to specified buffer. | |
virtual System::Size | write (const std::string &message) |
Writes message to this socket. | |
virtual System::Size | write (const char *buffer, System::Size maxLength) |
Writes up to maxLength bytes from the specified buffer to this socket. | |
System::FileDescriptor | getOriginalFileDescriptor () const |
Returns the original file descriptor associated with the socket on its creation. | |
virtual System::FileDescriptor | getFileDescriptorForTransport () const |
Returns the file descriptor that should be used for that socket to communicate with its peer(s). | |
virtual Port | getPeerPort () const |
Returns the remote port number this socket is linked to, i.e. | |
virtual IPAddress * | getLocalIPAddress () const |
Returns the local IP address corresponding to this socket. | |
virtual IPAddress * | getPeerIPAddress () const |
Returns the remote IP address this socket is linked to, i.e. | |
virtual System::StreamID | getInputStreamID () const |
Returns the file descriptor for this socket, which is a StreamID. | |
virtual System::StreamID | getOutputStreamID () const |
Returns the file descriptor for this socket, which is a StreamID. | |
bool | isSelected () const |
Tells if the stream has data to read. | |
bool | isFaulty () const |
virtual void | clearInput () |
Clears the input stream. | |
virtual Ceylan::Sint8 | readSint8 () |
Returns a Ceylan::Sint8 read from this input stream. | |
virtual Ceylan::Uint8 | readUint8 () |
Returns a Ceylan::Uint8 read from this input stream. | |
virtual Ceylan::Sint16 | readSint16 () |
Returns a Ceylan::Sint16 read from this input stream. | |
virtual Ceylan::Uint16 | readUint16 () |
Returns a Ceylan::Uint16 read from this input stream. | |
virtual Ceylan::Sint32 | readSint32 () |
Returns a Ceylan::Sint32 read from this input stream. | |
virtual Ceylan::Uint32 | readUint32 () |
Returns a Ceylan::Uint32 read from this input stream. | |
virtual Ceylan::Float32 | readFloat32 () |
Returns a Ceylan::Float32 read from this input stream. | |
virtual Ceylan::Float64 | readFloat64 () |
Returns a Ceylan::Float64 read from this input stream. | |
virtual void | readString (std::string &result) |
Reads a string from this input stream, and stores it in the specified string. | |
virtual void | skipWhitespaces (Ceylan::Uint8 &firstNonSpace) |
Reads from this input stream as long as there are whitespaces to be read. | |
bool | isBlocking () const |
Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false). | |
virtual void | writeSint8 (Ceylan::Sint8 toWrite) |
Writes a Ceylan::Sint8 to this output stream. | |
virtual void | writeUint8 (Ceylan::Uint8 toWrite) |
Writes a Ceylan::Uint8 to this output stream. | |
virtual void | writeSint16 (Ceylan::Sint16 toWrite) |
Writes a Ceylan::Sint16 to this output stream. | |
virtual void | writeUint16 (Ceylan::Uint16 toWrite) |
Writes a Ceylan::Uint16 to this output stream. | |
virtual void | writeSint32 (Ceylan::Sint32 toWrite) |
Writes a Ceylan::Sint32 to this output stream. | |
virtual void | writeUint32 (Ceylan::Uint32 toWrite) |
Writes a Ceylan::Uint32 to this output stream. | |
virtual void | writeFloat32 (Ceylan::Float32 toWrite) |
Writes a Ceylan::Uint32 to this output stream. | |
virtual void | writeFloat64 (Ceylan::Float64 toWrite) |
Writes a Ceylan::Uint32 to this output stream. | |
virtual void | writeString (const std::string &toWrite) |
Writes a string to this output stream. | |
Static Public Member Functions | |
static Ceylan::Uint16 | Select (std::list< InputStream * > &is) |
Blocks the calling thread until bytes become available on one or more streams in is. | |
static Ceylan::Uint16 | Test (std::list< InputStream * > &is) |
Checks whether bytes become available on one or more streams in is. | |
static bool | Close (FileDescriptor &fd) |
Closes and zeroes the specified file descriptor. | |
static const std::string | ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high) |
Returns a user-friendly description of this list of pointers to text displayable instances. | |
static TextOutputFormat | GetOutputFormat () |
Returns the current overall text format to be used by TextDisplayable instances. | |
static void | SetOutputFormat (TextOutputFormat newOutputFormat) |
Sets the current overall text format to be used by TextDisplayable instances. | |
Static Public Attributes | |
static const Ceylan::Uint32 | DefaultMaximumPendingConnectionsCount = 20 |
Default value of the maximum length the queue of pending connections. | |
Protected Member Functions | |
virtual bool | closeAcceptedConnections () |
Closes any accepted connection, including its socket. | |
virtual void | prepareToAccept () |
Prepares the socket for accepting connections. | |
virtual void | cleanAfterAccept () |
Restores the server state after an accepted connection is over, so that next connections in the queue can be accepted in turn. | |
virtual void | accepted (AnonymousStreamSocket &newConnection) |
Called whenever a new connection is established, i.e. | |
virtual bool | isRequestedToStop () const |
Tells whether this server will stop as soon as possible, no later than any current connection is over. | |
virtual void | requestToStop () |
Requests the server to stop just after having completed an eventual current connection. | |
virtual void | createSocket (Port port) |
Creates the stream (TCP) socket associated with the port port. | |
virtual void | setNagleAlgorithmTo (bool activated) |
Enables or disables the Nagle algorithm for this socket. | |
virtual bool | close () |
Closes the socket. | |
virtual void | setSelected (bool newStatus) |
Used to set the selection status of this stream. | |
void | setFaulty (bool newFaultyState=true) |
Sets the faulty state of this stream. | |
virtual void | setStreamID (StreamID newInputStreamID) |
Sets this input stream's unique ID. | |
Protected Attributes | |
std::set< AnonymousStreamSocket * > | _currentConnections |
The list of current accepted connection-based anonymous sockets. | |
bool | _bound |
Tells whether this server socket is already bound, i.e. | |
bool | _nagleAlgorithmDeactivated |
Tells whether the Nagle algorithm is requested to be deactivated, so that the snappiest possible response (packet timing) is searched for (if true), even though it would be obtained at the expense of usable network bandwidth. | |
Port | _port |
The port this socket is created with. | |
SystemSpecificSocketAddress * | _address |
The system-specific socket address for this socket. | |
System::FileDescriptor | _originalFD |
Internal file descriptor, used if this feature is available. | |
bool | _isBlocking |
Stores whether the stream is in blocking mode. | |
Static Protected Attributes | |
static TextOutputFormat | _OutputFormat = rawText |
The text format to be used currently by TextDisplayable instances. | |
Private Member Functions | |
MultiplexedServerStreamSocket (const MultiplexedServerStreamSocket &source) | |
Copy constructor made private to ensure that it will be never called. | |
MultiplexedServerStreamSocket & | operator= (const MultiplexedServerStreamSocket &source) |
Assignment operator made private to ensure that it will be never called. |
This server basically manages n+1 sockets: the listening one, which, whenever incoming connections are accepted, leads to a new socket being created, and n simultaneously connected sockets, each one being viewed as an anonymous socket dedicated to one of the living connections.
Following methods have to be subclassed so that the server can perform its specific task:
Following methods may be subclassed for specific servers:
Inherited read/write methods communicate with the listening socket, as there may be more than one living connection at a time, which therefore would need to be specifically chosen thanks to the interface.
Definition at line 91 of file CeylanMultiplexedServerStreamSocket.h.
enum Ceylan::TextDisplayable::TextOutputFormat [inherited] |
Defines what text output formats for TextDisplayable instances are available.
Definition at line 124 of file CeylanTextDisplayable.h.
MultiplexedServerStreamSocket::MultiplexedServerStreamSocket | ( | Port | listeningPort, | |
bool | reuse = true | |||
) | [explicit] |
Constructs a new multiplexed non-blocking server-side socket.
listeningPort | the TCP port of this listening server socket. | |
reuse | tells whether the local addresses are allowed to be reused in bind(). |
SocketException | if socket creation failed. |
Definition at line 101 of file CeylanMultiplexedServerStreamSocket.cc.
MultiplexedServerStreamSocket::~MultiplexedServerStreamSocket | ( | ) | throw () [virtual] |
Virtual destructor.
Definition at line 123 of file CeylanMultiplexedServerStreamSocket.cc.
References closeAcceptedConnections().
Ceylan::Network::MultiplexedServerStreamSocket::MultiplexedServerStreamSocket | ( | const MultiplexedServerStreamSocket & | source | ) | [private] |
Copy constructor made private to ensure that it will be never called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
AnonymousStreamSocket * MultiplexedServerStreamSocket::accept | ( | ) | [virtual] |
Accepts all incoming connections, as long as it is not requested to stop.
If there is no pending connection present on the queue, blocks the caller until a connection is present.
ServerStreamSocketException | on failure. |
Implements Ceylan::Network::ServerStreamSocket.
Reimplemented in Ceylan::Network::MultiplexedProtocolBasedStreamServer.
Definition at line 399 of file CeylanMultiplexedServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::_bound, _currentConnections, Ceylan::Network::ServerStreamSocket::accepted(), dataUtils::e, Ceylan::Network::Socket::getOriginalFileDescriptor(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), Ceylan::Exception::toString(), and toString().
Referenced by run().
void ServerStreamSocket::accepted | ( | AnonymousStreamSocket & | newConnection | ) | [protected, virtual, inherited] |
Called whenever a new connection is established, i.e.
when the accept method succeeds.
It is up to this method, designed to be overriden, to handle the connection from its start to its end, and then to return so that this server gains back the socket control.
If this server has to handle (potentially sequentially) multiple clients, then the overriden implementation of this method should end up by cleaning this accepted connection. And the server must loop with regular calls to the accept method.
newConnection | the connection-related socket is specified, so that the user code can use it to perform its task. |
ServerStreamSocketException | on failure. |
Reimplemented in Ceylan::Network::MultiplexedProtocolBasedStreamServer.
Definition at line 379 of file CeylanServerStreamSocket.cc.
References DISPLAY_NET_DEBUG, and Ceylan::Network::AnonymousStreamSocket::toString().
Referenced by Ceylan::Network::SequentialServerStreamSocket::accept(), and accept().
void ServerStreamSocket::cleanAfterAccept | ( | ) | [protected, virtual, inherited] |
Restores the server state after an accepted connection is over, so that next connections in the queue can be accepted in turn.
ServerStreamSocketException | if the operation failed. |
Definition at line 358 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::closeAcceptedConnections(), and DISPLAY_NET_DEBUG.
Referenced by Ceylan::Network::SequentialServerStreamSocket::accept().
void InputStream::clearInput | ( | ) | [virtual, inherited] |
Clears the input stream.
InputStream::ReadFailedException | if the operation failed. |
Reimplemented in Ceylan::System::Pipe.
Definition at line 179 of file CeylanInputStream.cc.
References dataUtils::b, Ceylan::System::InputStream::hasAvailableData(), and Ceylan::System::InputStream::read().
bool Stream::Close | ( | FileDescriptor & | fd | ) | [static, inherited] |
Closes and zeroes the specified file descriptor.
It is passed by address so that this function can set it to zero on successful close.
CloseException | if the close operation failed. |
Definition at line 114 of file CeylanStream.cc.
References Ceylan::System::Stream::close(), generalUtils::false, Ceylan::toString(), and generalUtils::true.
Referenced by Ceylan::System::StandardFile::close(), Ceylan::Network::Socket::close(), Ceylan::System::Pipe::close(), and Ceylan::System::LibfatFile::close().
bool Socket::close | ( | ) | [protected, virtual, inherited] |
Closes the socket.
CloseException | if the close operation failed. |
Implements Ceylan::System::Stream.
Definition at line 553 of file CeylanSocket.cc.
References Ceylan::Network::Socket::_originalFD, Ceylan::System::Stream::Close(), Ceylan::Network::explainSocketError(), generalUtils::false, and generalUtils::true.
Referenced by Ceylan::Network::ClientStreamSocket::disconnect(), and Ceylan::Network::Socket::~Socket().
bool MultiplexedServerStreamSocket::closeAcceptedConnections | ( | ) | [protected, virtual] |
Closes any accepted connection, including its socket.
CloseException | if the close operation failed. |
Implements Ceylan::Network::ServerStreamSocket.
Definition at line 533 of file CeylanMultiplexedServerStreamSocket.cc.
References _currentConnections, and generalUtils::true.
Referenced by ~MultiplexedServerStreamSocket().
void MultiplexedServerStreamSocket::closeConnection | ( | AnonymousStreamSocket & | connection | ) | [virtual] |
Closes specified connection.
connection | a reference to the connection that is to be terminated by this server. |
Reimplemented in Ceylan::Network::MultiplexedProtocolBasedStreamServer.
Definition at line 472 of file CeylanMultiplexedServerStreamSocket.cc.
References _currentConnections, and Ceylan::Network::AnonymousStreamSocket::toString().
Referenced by run().
void StreamSocket::createSocket | ( | Port | port | ) | [protected, virtual, inherited] |
Creates the stream (TCP) socket associated with the port port.
SocketException | if the operation failed. |
Implements Ceylan::Network::Socket.
Definition at line 201 of file CeylanStreamSocket.cc.
References Ceylan::Network::Socket::_address, Ceylan::Network::Socket::_originalFD, Ceylan::Network::Socket::_port, dataUtils::e, Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::System::Stream::isBlocking(), Ceylan::Network::StreamSocket::setBlocking(), Ceylan::Exception::toString(), and Ceylan::toString().
Referenced by Ceylan::Network::ClientStreamSocket::connect(), and Ceylan::Network::StreamSocket::StreamSocket().
FileDescriptor Socket::getFileDescriptorForTransport | ( | ) | const [virtual, inherited] |
Returns the file descriptor that should be used for that socket to communicate with its peer(s).
SocketException | if the operation failed, or FeatureNotAvailableException if the file descriptor feature is not available. |
Reimplemented in Ceylan::Network::SequentialServerStreamSocket.
Definition at line 389 of file CeylanSocket.cc.
References Ceylan::Network::Socket::_originalFD.
Referenced by Ceylan::Network::Socket::getInputStreamID(), Ceylan::Network::Socket::getOutputStreamID(), Ceylan::Network::Socket::hasAvailableData(), Ceylan::Network::StreamSocket::setNagleAlgorithmTo(), Ceylan::Network::Socket::toString(), and Ceylan::Network::Socket::write().
StreamID Socket::getInputStreamID | ( | ) | const [virtual, inherited] |
Returns the file descriptor for this socket, which is a StreamID.
InputStreamException | if no identifier is available, or if the file descriptor feature is not available. |
Implements Ceylan::System::InputStream.
Definition at line 446 of file CeylanSocket.cc.
References Ceylan::Network::Socket::getFileDescriptorForTransport(), and Ceylan::Exception::toString().
IPAddress * Socket::getLocalIPAddress | ( | ) | const [virtual, inherited] |
Returns the local IP address corresponding to this socket.
Ownership of the returned object is transferred to the caller, which has to deallocate it when of no more use.
SocketException | if this operation failed. |
Definition at line 426 of file CeylanSocket.cc.
Port ServerStreamSocket::getLocalPort | ( | ) | const [virtual, inherited] |
Returns the local port number of the socket.
SocketException | if this operation failed. |
Reimplemented from Ceylan::Network::Socket.
Definition at line 203 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::Socket::_port.
ServerStreamSocket::ConnectionCount ServerStreamSocket::getMaximumPendingConnectionsCount | ( | ) | const [virtual, inherited] |
Returns the current maximum number of pending connections for this socket.
Definition at line 213 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::_maximumPendingConnectionsCount.
Referenced by Ceylan::Network::ServerStreamSocket::toString().
FileDescriptor Socket::getOriginalFileDescriptor | ( | ) | const [inherited] |
Returns the original file descriptor associated with the socket on its creation.
This file descriptor does not change, both for client and server sides.
SocketException | if the operation failed, or FeatureNotAvailableException if the file descriptor feature is not available. |
Definition at line 371 of file CeylanSocket.cc.
References Ceylan::Network::Socket::_originalFD.
Referenced by Ceylan::Network::SequentialServerStreamSocket::accept(), accept(), Ceylan::Network::MultiplexedProtocolBasedStreamServer::accept(), Ceylan::Network::ClientStreamSocket::connect(), Ceylan::Network::SequentialServerStreamSocket::getFileDescriptorForTransport(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), run(), Ceylan::Network::ServerStreamSocket::ServerStreamSocket(), Ceylan::Network::StreamSocket::setBlocking(), and Ceylan::Network::Socket::toString().
TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat | ( | ) | [static, inherited] |
Returns the current overall text format to be used by TextDisplayable instances.
Definition at line 63 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::formatStringList(), Ceylan::formatStringMap(), Ceylan::XML::XMLMarkup::toString(), Ceylan::Maths::Linear::Vector3::toString(), Ceylan::Maths::Linear::Vector2::toString(), Ceylan::Maths::Linear::Tripoint::toString(), Ceylan::Module::toString(), Ceylan::Maths::Linear::Matrix3::toString(), Ceylan::Maths::Linear::Matrix2::toString(), Ceylan::Maths::Linear::HomogeneousMatrix3::toString(), and Ceylan::Maths::Linear::Bipoint::toString().
StreamID Socket::getOutputStreamID | ( | ) | const [virtual, inherited] |
Returns the file descriptor for this socket, which is a StreamID.
OutputStreamException | if no identifier is available, or if the file descriptor feature is not available. |
Implements Ceylan::System::OutputStream.
Definition at line 473 of file CeylanSocket.cc.
References Ceylan::Network::Socket::getFileDescriptorForTransport(), and Ceylan::Exception::toString().
IPAddress * Socket::getPeerIPAddress | ( | ) | const [virtual, inherited] |
Returns the remote IP address this socket is linked to, i.e.
the IP address of the peer of this socket.
SocketException | if this operation failed, including if this socket is not connected. |
Definition at line 436 of file CeylanSocket.cc.
Port Socket::getPeerPort | ( | ) | const [virtual, inherited] |
Returns the remote port number this socket is linked to, i.e.
the port of the peer of this socket.
SocketException | if this operation failed, including if this socket is not connected. |
Reimplemented in Ceylan::Network::ClientStreamSocket.
Definition at line 417 of file CeylanSocket.cc.
virtual bool Ceylan::Network::MultiplexedServerStreamSocket::handleConnection | ( | AnonymousStreamSocket & | connection | ) | [pure virtual] |
Manages a connection for which data is available.
The server calls regularly this method, as soon as a connection has data waiting to be read. This method, designed to be overriden so that the connection can be managed according to the user needs, is expected to read these data, to process them and, if needed, to write data back to the corresponding client.
Then this method must return so that this server can go on serving requests.
These slices of communication should not be too long, otherwise such request being processed would freeze all other connections.
This method is to be subclassed so that this multiplexed server can perform its task on each per-connection socket, viewed as an abstract input/output stream.
connection | the connection-based anonymous socket in charge of this connection that has data to be read. |
MultiplexedServerStreamSocketException | if an error occurred, and more precisely its NetworkServerShutdownException child class whenever a connection determined that the network server should be stopped. |
Implemented in Ceylan::Network::MultiplexedProtocolBasedStreamServer.
Referenced by run().
bool Socket::hasAvailableData | ( | ) | const [virtual, inherited] |
Tells whether there is data available on input, i.e.
on the file descriptor used for transport.
Implements Ceylan::System::InputStream.
Definition at line 226 of file CeylanSocket.cc.
References dataUtils::e, generalUtils::false, Ceylan::Network::Socket::getFileDescriptorForTransport(), Ceylan::System::HasAvailableData(), and Ceylan::Exception::toString().
bool Stream::isBlocking | ( | ) | const [inherited] |
Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false).
Definition at line 93 of file CeylanStream.cc.
References Ceylan::System::Stream::_isBlocking.
Referenced by Ceylan::Network::StreamSocket::createSocket(), and Ceylan::Network::Socket::toString().
bool MultiplexedServerStreamSocket::isConnected | ( | ) | const [virtual] |
Tells whether this socket is currently connected to a client.
Implements Ceylan::Network::Socket.
Definition at line 136 of file CeylanMultiplexedServerStreamSocket.cc.
References _currentConnections.
bool InputStream::isFaulty | ( | ) | const [inherited] |
Definition at line 131 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::_isFaulty.
Referenced by Ceylan::System::InputStream::toString().
bool ServerStreamSocket::isRequestedToStop | ( | ) | const [protected, virtual, inherited] |
Tells whether this server will stop as soon as possible, no later than any current connection is over.
Definition at line 391 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::_stopRequested.
Referenced by Ceylan::Network::ServerStreamSocket::run(), and run().
bool InputStream::isSelected | ( | ) | const [inherited] |
Tells if the stream has data to read.
Definition at line 122 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::_isSelected.
Referenced by Ceylan::System::InputStream::toString().
MultiplexedServerStreamSocket& Ceylan::Network::MultiplexedServerStreamSocket::operator= | ( | const MultiplexedServerStreamSocket & | source | ) | [private] |
Assignment operator made private to ensure that it will be never called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
void ServerStreamSocket::prepareToAccept | ( | ) | [protected, virtual, inherited] |
Prepares the socket for accepting connections.
It calls bind() and listen().
ServerStreamSocketException | if the operation failed, including if bind or listen failed. |
Definition at line 273 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::Socket::_address, Ceylan::Network::ServerStreamSocket::_bound, Ceylan::Network::ServerStreamSocket::_maximumPendingConnectionsCount, Ceylan::Network::StreamSocket::_nagleAlgorithmDeactivated, DISPLAY_NET_DEBUG, Ceylan::System::explainError(), Ceylan::Network::Socket::getOriginalFileDescriptor(), Ceylan::Network::StreamSocket::setNagleAlgorithmTo(), Ceylan::toString(), and generalUtils::true.
Referenced by Ceylan::Network::SequentialServerStreamSocket::accept(), accept(), Ceylan::Network::MultiplexedProtocolBasedStreamServer::accept(), and run().
virtual System::Size Ceylan::Network::Socket::read | ( | char * | buffer, | |
System::Size | maxLength | |||
) | [virtual, inherited] |
Reads up to maxLength bytes from this socket to specified buffer.
buffer | the buffer where to store read bytes. Its size must be at least maxLength bytes. | |
maxLength | the maximum number of bytes that should be read. |
ReadFailedException | if a read error occurred. |
Reimplemented from Ceylan::System::InputStream.
Ceylan::Float32 InputStream::readFloat32 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Float32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 356 of file CeylanInputStream.cc.
References ceylan_bswap_32, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat32().
Ceylan::Float64 InputStream::readFloat64 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Float64 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 392 of file CeylanInputStream.cc.
References Ceylan::byteswap(), ceylan_bswap_64, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat64().
Ceylan::Sint16 InputStream::readSint16 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Sint16 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 239 of file CeylanInputStream.cc.
References ceylan_bswap_16, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint16().
Ceylan::Sint32 InputStream::readSint32 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Sint32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 298 of file CeylanInputStream.cc.
References ceylan_bswap_32, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint32().
Ceylan::Sint8 InputStream::readSint8 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Sint8 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 203 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint8().
void InputStream::readString | ( | std::string & | result | ) | [virtual, inherited] |
Reads a string from this input stream, and stores it in the specified string.
result | the string to fill from this input stream. |
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 437 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::read(), Ceylan::System::InputStream::readUint16(), and Ceylan::toString().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeString().
Ceylan::Uint16 InputStream::readUint16 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Uint16 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 268 of file CeylanInputStream.cc.
References ceylan_bswap_16, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint16(), and Ceylan::System::InputStream::readString().
Ceylan::Uint32 InputStream::readUint32 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Uint32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 327 of file CeylanInputStream.cc.
References ceylan_bswap_32, and Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint32().
Ceylan::Uint8 InputStream::readUint8 | ( | ) | [virtual, inherited] |
Returns a Ceylan::Uint8 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 221 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint8(), Ceylan::System::FileSystemManager::diff(), Ceylan::XML::XMLParser::handleNextElement(), Ceylan::XML::XMLParser::InterpretLowerThanSequence(), Ceylan::XML::XMLParser::InterpretXMLDeclaration(), and Ceylan::System::InputStream::skipWhitespaces().
void ServerStreamSocket::requestToStop | ( | ) | [protected, virtual, inherited] |
Requests the server to stop just after having completed an eventual current connection.
Multiple stop requests can be sent.
Definition at line 400 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::_stopRequested, DISPLAY_NET_DEBUG, and generalUtils::true.
Referenced by Ceylan::Network::MultiplexedProtocolBasedStreamServer::closeConnection().
void MultiplexedServerStreamSocket::run | ( | ) | [virtual] |
Activates this server so that it can handle incoming requests in parallel.
This main loop while last as long as the server is not requested to stop.
Reimplemented from Ceylan::Network::ServerStreamSocket.
Definition at line 145 of file CeylanMultiplexedServerStreamSocket.cc.
References _currentConnections, accept(), Ceylan::System::Signal::BrokenPipe, closeConnection(), dataUtils::e, Ceylan::Network::Socket::getOriginalFileDescriptor(), handleConnection(), Ceylan::System::Signal::ignore(), Ceylan::Network::ServerStreamSocket::isRequestedToStop(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), Ceylan::System::InputStream::Select(), Ceylan::System::InputStream::setFaulty(), Ceylan::Exception::toString(), Ceylan::Network::AnonymousStreamSocket::toString(), Ceylan::toString(), and toString().
Ceylan::Uint16 InputStream::Select | ( | std::list< InputStream * > & | is | ) | [static, inherited] |
Blocks the calling thread until bytes become available on one or more streams in is.
To see which are selected, use the isSelected
method.
SelectFailedException | if the operation failed, for example if the file descriptor feature is not available on this platform. |
Definition at line 534 of file CeylanInputStream.cc.
References Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::System::getError(), Ceylan::Network::getSocketError(), Ceylan::System::Thread::Sleep(), and Ceylan::toString().
Referenced by run().
void StreamSocket::setBlocking | ( | bool | newStatus | ) | [virtual, inherited] |
Sets the blocking mode of this stream socket.
newStatus | if true, sets the socket in blocking mode, if false set to non-blocking mode. If the socket is already in the target state, nothing is done. |
NonBlockingNotSupportedException | if the operation failed. |
Reimplemented from Ceylan::Network::Socket.
Definition at line 381 of file CeylanStreamSocket.cc.
References Ceylan::System::Stream::_isBlocking, Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::Network::Socket::getOriginalFileDescriptor(), and Ceylan::toString().
Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), and Ceylan::Network::StreamSocket::createSocket().
void InputStream::setFaulty | ( | bool | newFaultyState = true |
) | [protected, inherited] |
Sets the faulty state of this stream.
newFaultyState | the new faulty state. |
Definition at line 1004 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::_isFaulty.
Referenced by run().
void ServerStreamSocket::setMaximumPendingConnectionsCount | ( | ConnectionCount | newMax | ) | [virtual, inherited] |
Sets the current maximum number of pending connections for this socket.
Definition at line 222 of file CeylanServerStreamSocket.cc.
References Ceylan::Network::ServerStreamSocket::_maximumPendingConnectionsCount.
void StreamSocket::setNagleAlgorithmTo | ( | bool | activated | ) | [protected, virtual, inherited] |
Enables or disables the Nagle algorithm for this socket.
activated | if true, activates the algorithm, if false, deactivates it. |
Definition at line 287 of file CeylanStreamSocket.cc.
References Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::Network::Socket::getFileDescriptorForTransport(), and Ceylan::toString().
Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), Ceylan::Network::ClientStreamSocket::connect(), and Ceylan::Network::ServerStreamSocket::prepareToAccept().
void TextDisplayable::SetOutputFormat | ( | TextOutputFormat | newOutputFormat | ) | [static, inherited] |
Sets the current overall text format to be used by TextDisplayable instances.
newOutputFormat | the new output format. |
Definition at line 72 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::Log::LogHolder::LogHolder().
void InputStream::setSelected | ( | bool | newStatus | ) | [protected, virtual, inherited] |
Used to set the selection status of this stream.
Definition at line 989 of file CeylanInputStream.cc.
References Ceylan::System::InputStream::_isSelected, Ceylan::System::InputStream::getInputStreamID(), and Ceylan::toString().
Referenced by Ceylan::System::StandardFile::read(), Ceylan::System::Pipe::read(), and Ceylan::System::LibfatFile::read().
void InputStream::setStreamID | ( | StreamID | newInputStreamID | ) | [protected, virtual, inherited] |
Sets this input stream's unique ID.
InputStreamException | in all cases as long as not specifically overriden. |
Definition at line 1013 of file CeylanInputStream.cc.
void InputStream::skipWhitespaces | ( | Ceylan::Uint8 & | firstNonSpace | ) | [virtual, inherited] |
Reads from this input stream as long as there are whitespaces to be read.
firstNonSpace | the variable which will be set by this method to the value of the first non-whitespace character that is read. |
Definition at line 516 of file CeylanInputStream.cc.
References Ceylan::isWhitespace(), and Ceylan::System::InputStream::readUint8().
Referenced by Ceylan::XML::XMLParser::handleNextElement().
Ceylan::Uint16 InputStream::Test | ( | std::list< InputStream * > & | is | ) | [static, inherited] |
Checks whether bytes become available on one or more streams in is.
To see which are selected, use the isSelected
method.
This method returns always immediatly.
SelectFailedException | if the operation failed, for example if the file descriptor feature is not available on this platform. |
Definition at line 863 of file CeylanInputStream.cc.
References Ceylan::System::explainError(), and Ceylan::System::getError().
const std::string TextDisplayable::ToString | ( | std::list< TextDisplayable * > | displayables, | |
Ceylan::VerbosityLevels | level = Ceylan::high | |||
) | [static, inherited] |
Returns a user-friendly description of this list of pointers to text displayable instances.
displayables | a list of pointers to TextDisplayable instances/ | |
level | the requested verbosity level. |
Definition at line 45 of file CeylanTextDisplayable.cc.
References Ceylan::formatStringList().
const std::string MultiplexedServerStreamSocket::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns a user-friendly description of the state of this object.
level | the requested verbosity level. |
Reimplemented from Ceylan::Network::ServerStreamSocket.
Reimplemented in Ceylan::Network::MultiplexedProtocolBasedStreamServer.
Definition at line 491 of file CeylanMultiplexedServerStreamSocket.cc.
References _currentConnections, Ceylan::formatStringList(), and Ceylan::medium.
virtual System::Size Ceylan::Network::Socket::write | ( | const char * | buffer, | |
System::Size | maxLength | |||
) | [virtual, inherited] |
Writes up to maxLength bytes from the specified buffer to this socket.
buffer | the buffer where to find bytes that must be written to this socket. Its size must be at least maxLength bytes. |
WriteFailedException | if a write error occurred. |
Reimplemented from Ceylan::System::OutputStream.
Size Socket::write | ( | const std::string & | message | ) | [virtual, inherited] |
Writes message to this socket.
message | the message to write to this socket. |
WriteFailedException | if a write error occurred. |
Reimplemented from Ceylan::System::OutputStream.
Definition at line 294 of file CeylanSocket.cc.
References Ceylan::System::explainError(), Ceylan::System::FDWrite(), Ceylan::Network::Socket::getFileDescriptorForTransport(), and Ceylan::Exception::toString().
void OutputStream::writeFloat32 | ( | Ceylan::Float32 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Uint32 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 219 of file CeylanOutputStream.cc.
References ceylan_bswap_32, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeFloat32().
void OutputStream::writeFloat64 | ( | Ceylan::Float64 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Uint32 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 247 of file CeylanOutputStream.cc.
References Ceylan::byteswap(), ceylan_bswap_64, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeFloat64().
void OutputStream::writeSint16 | ( | Ceylan::Sint16 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Sint16 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 119 of file CeylanOutputStream.cc.
References ceylan_bswap_16, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint16().
void OutputStream::writeSint32 | ( | Ceylan::Sint32 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Sint32 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 169 of file CeylanOutputStream.cc.
References ceylan_bswap_32, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint32().
void OutputStream::writeSint8 | ( | Ceylan::Sint8 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Sint8 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 89 of file CeylanOutputStream.cc.
References Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint8().
void OutputStream::writeString | ( | const std::string & | toWrite | ) | [virtual, inherited] |
Writes a string to this output stream.
toWrite | the string to write to this output stream. |
WriteFailedException | in case a system error occured. |
Definition at line 286 of file CeylanOutputStream.cc.
References Ceylan::Log::LogPlug::debug(), Ceylan::toString(), Ceylan::Uint16Max, Ceylan::System::OutputStream::write(), and Ceylan::System::OutputStream::writeUint16().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeString().
void OutputStream::writeUint16 | ( | Ceylan::Uint16 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Uint16 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 144 of file CeylanOutputStream.cc.
References ceylan_bswap_16, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint16(), and Ceylan::System::OutputStream::writeString().
void OutputStream::writeUint32 | ( | Ceylan::Uint32 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Uint32 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 194 of file CeylanOutputStream.cc.
References ceylan_bswap_32, and Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint32().
void OutputStream::writeUint8 | ( | Ceylan::Uint8 | toWrite | ) | [virtual, inherited] |
Writes a Ceylan::Uint8 to this output stream.
WriteFailedException | in case a system error occured. |
Definition at line 104 of file CeylanOutputStream.cc.
References Ceylan::System::OutputStream::write().
Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint8(), and Ceylan::XML::XMLSavingVisitor::visit().
SystemSpecificSocketAddress* Ceylan::Network::Socket::_address [protected, inherited] |
The system-specific socket address for this socket.
It will be used by server sockets to bind to the target port, whereas client sockets will use it to connect to the target server, and anonymous sockets will store informations about the client.
Definition at line 454 of file CeylanSocket.h.
Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), Ceylan::Network::ClientStreamSocket::connect(), Ceylan::Network::StreamSocket::createSocket(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), Ceylan::Network::Socket::Socket(), and Ceylan::Network::Socket::~Socket().
bool Ceylan::Network::ServerStreamSocket::_bound [protected, inherited] |
Tells whether this server socket is already bound, i.e.
if a bind operation has already been performed successfully.
Definition at line 334 of file CeylanServerStreamSocket.h.
Referenced by Ceylan::Network::SequentialServerStreamSocket::accept(), accept(), Ceylan::Network::MultiplexedProtocolBasedStreamServer::accept(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), and Ceylan::Network::ServerStreamSocket::toString().
std::set<AnonymousStreamSocket *> Ceylan::Network::MultiplexedServerStreamSocket::_currentConnections [protected] |
The list of current accepted connection-based anonymous sockets.
It is a set of pointers and not a list, since not only it has to be enumerated, but also it has to be searched for specific elements (with find).
Definition at line 334 of file CeylanMultiplexedServerStreamSocket.h.
Referenced by accept(), Ceylan::Network::MultiplexedProtocolBasedStreamServer::accept(), closeAcceptedConnections(), closeConnection(), Ceylan::Network::MultiplexedProtocolBasedStreamServer::closeConnection(), isConnected(), run(), toString(), and Ceylan::Network::MultiplexedProtocolBasedStreamServer::toString().
bool Ceylan::System::Stream::_isBlocking [protected, inherited] |
Stores whether the stream is in blocking mode.
Definition at line 221 of file CeylanStream.h.
Referenced by Ceylan::System::Stream::isBlocking(), Ceylan::Network::StreamSocket::setBlocking(), Ceylan::Network::Socket::setBlocking(), and Ceylan::System::Stream::toString().
bool Ceylan::Network::StreamSocket::_nagleAlgorithmDeactivated [protected, inherited] |
Tells whether the Nagle algorithm is requested to be deactivated, so that the snappiest possible response (packet timing) is searched for (if true), even though it would be obtained at the expense of usable network bandwidth.
This is seldom recommended except for remote GUI or multiplayer network games.
Hence the default is false, and the Nagle algorithm is used.
Deactivating the Nagle algorithm is to be performed in socket child classes.
Definition at line 223 of file CeylanStreamSocket.h.
Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), Ceylan::Network::ClientStreamSocket::connect(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), and Ceylan::Network::StreamSocket::toString().
System::FileDescriptor Ceylan::Network::Socket::_originalFD [protected, inherited] |
Internal file descriptor, used if this feature is available.
The local port this socket will be bound to.
This is the original file descriptor for this socket. Depending on the specialization of this socket, it may or may not be the file descriptor that is used for transport.
Definition at line 472 of file CeylanSocket.h.
Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), Ceylan::Network::Socket::close(), Ceylan::Network::StreamSocket::createSocket(), Ceylan::Network::Socket::getFileDescriptorForTransport(), Ceylan::Network::Socket::getOriginalFileDescriptor(), and Ceylan::Network::AnonymousStreamSocket::toString().
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited] |
The text format to be used currently by TextDisplayable instances.
Definition at line 158 of file CeylanTextDisplayable.h.
Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().
Port Ceylan::Network::Socket::_port [protected, inherited] |
The port this socket is created with.
For client sockets, the port of the remote server will be recorded here.
For server sockets, it will be the local port where the server will be listening.
Definition at line 441 of file CeylanSocket.h.
Referenced by Ceylan::Network::StreamSocket::createSocket(), Ceylan::Network::ServerStreamSocket::getLocalPort(), Ceylan::Network::ClientStreamSocket::getPeerPort(), and Ceylan::Network::StreamSocket::StreamSocket().
const Ceylan::Uint32 Ceylan::Network::ServerStreamSocket::DefaultMaximumPendingConnectionsCount = 20 [static, inherited] |
Default value of the maximum length the queue of pending connections.
Definition at line 204 of file CeylanServerStreamSocket.h.