21 #ifndef G_NET_SOCKET_PROTOCOL__H
22 #define G_NET_SOCKET_PROTOCOL__H
33 class SocketProtocol ;
34 class SocketProtocolImp ;
35 class SocketProtocolSink ;
57 G_EXCEPTION_CLASS( ReadError ,
"peer disconnected" ) ;
58 G_EXCEPTION( SendError ,
"peer disconnected" ) ;
59 G_EXCEPTION( SecureConnectionTimeout ,
"secure connection timeout" ) ;
62 StreamSocket & ,
unsigned int secure_connection_timeout ) ;
83 bool send(
const std::string & data ,
size_t offset = 0U ) ;
96 bool send(
const std::vector<std::pair<const char *,size_t> > & data ) ;
143 virtual void onData(
const char * ,
size_t ) = 0 ;
146 virtual void onSecure(
const std::string & peer_certificate ) = 0 ;
void readEvent()
Called on receipt of a read event.
void otherEvent(EventHandler::Reason)
Called on receipt of an 'other' 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.
A pimple-pattern implementation class used by GNet::SocketProtocol.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
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.
void secureAccept()
Waits for the TLS/SSL handshake protocol, acting as a server.
bool send(const std::string &data, size_t offset=0U)
Sends data.
A base class for classes that handle asynchronous events from the event loop.
static bool secureAcceptCapable()
Returns true if the implementation supports TLS/SSL and a "server" profile has been configured...
void secureConnect()
Initiates the TLS/SSL handshake, acting as a client.
SocketProtocol(EventHandler &, ExceptionHandler &, Sink &, StreamSocket &, unsigned int secure_connection_timeout)
Constructor. The references are kept.
static bool secureConnectCapable()
Returns true if the implementation supports TLS/SSL and a "client" profile has been configured...
An interface used by GNet::SocketProtocol 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...
static void setReadBufferSize(size_t n)
Sets the read buffer size. Used in testing.
bool writeEvent()
Called on receipt of a write event.