21 #ifndef G_SOCKET_PROTOCOL_H
22 #define G_SOCKET_PROTOCOL_H
34 class SocketProtocol ;
35 class SocketProtocolImp ;
36 class SocketProtocolSink ;
58 G_EXCEPTION_CLASS( ReadError ,
"peer disconnected" ) ;
59 G_EXCEPTION( SendError ,
"peer disconnected" ) ;
60 G_EXCEPTION( SecureConnectionTimeout ,
"secure connection timeout" ) ;
77 bool send(
const std::string & data ,
size_t offset = 0U ) ;
88 bool send(
const std::vector<std::pair<const char *,size_t> > & data ) ;
129 virtual void onData(
const char * ,
size_t ) = 0 ;
132 virtual void onSecure(
const std::string & peer_certificate ) = 0 ;
void readEvent()
Called on receipt of a read event.
virtual void onData(const char *, size_t)=0
Called when data is read from the socket.
virtual ~SocketProtocolSink()
Destructor.
virtual void onSecure(const std::string &peer_certificate)=0
Called once the secure socket protocol has been successfully negotiated.
void sslAccept()
Accepts the TLS/SSL protocol.
A pimple-pattern implementation class used by GNet::SocketProtocol.
std::string peerCertificate() const
Returns the peer's TLS/SSL certificate or the empty string.
A derivation of GNet::Socket for a stream socket.
~SocketProtocol()
Destructor.
bool send(const std::string &data, size_t offset=0U)
Sends data.
SocketProtocol(EventHandler &, Sink &, StreamSocket &, unsigned int secure_connection_timeout)
Constructor. The references are kept.
A base class for classes that handle asynchronous events from the event loop.
static bool sslCapable()
Returns true if the implementation supports TLS/SSL.
void sslConnect()
Initiates the TLS/SSL protocol.
to deliver data from a socket.
An interface for implementing a low-level TLS/SSL protocol layer on top of a connected non-blocking s...
bool sslEnabled() const
Returns true if TLS/SSL is active.
bool writeEvent()
Called on receipt of a write event.