Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cTCPLink Class Referenceabstract

Interface that provides the methods available on a single TCP connection. More...

#include <Network.h>

Inheritance diagram for cTCPLink:
Inheritance graph
[legend]

Classes

class  cCallbacks
 

Public Types

typedef std::shared_ptr< cCallbackscCallbacksPtr
 

Public Member Functions

virtual void Close (void)=0
 Drops the connection without any more processing. More...
 
cCallbacksPtr GetCallbacks (void) const
 Returns the callbacks that are used. More...
 
virtual AString GetLocalIP (void) const =0
 Returns the IP address of the local endpoint of the connection. More...
 
virtual UInt16 GetLocalPort (void) const =0
 Returns the port used by the local endpoint of the connection. More...
 
virtual AString GetRemoteIP (void) const =0
 Returns the IP address of the remote endpoint of the connection. More...
 
virtual UInt16 GetRemotePort (void) const =0
 Returns the port used by the remote endpoint of the connection. More...
 
bool Send (const AString &a_Data)
 Queues the specified data for sending to the remote peer. More...
 
virtual bool Send (const void *a_Data, size_t a_Length)=0
 Queues the specified data for sending to the remote peer. More...
 
virtual void Shutdown (void)=0
 Closes the link gracefully. More...
 
virtual AString StartTLSClient (cX509CertPtr a_OwnCert, cCryptoKeyPtr a_OwnPrivKey, cX509CertPtr a_TrustedRootCAs)=0
 Starts a TLS handshake as a client connection. More...
 
virtual AString StartTLSServer (cX509CertPtr a_OwnCert, cCryptoKeyPtr a_OwnPrivKey, const AString &a_StartTLSData)=0
 Starts a TLS handshake as a server connection. More...
 
virtual ~cTCPLink ()
 

Protected Member Functions

 cTCPLink (cCallbacksPtr a_Callbacks)
 Creates a new link, with the specified callbacks. More...
 

Protected Attributes

cCallbacksPtr m_Callbacks
 Callbacks to be used for the various situations. More...
 

Friends

class cNetwork
 

Detailed Description

Interface that provides the methods available on a single TCP connection.

Definition at line 41 of file Network.h.

Member Typedef Documentation

◆ cCallbacksPtr

typedef std::shared_ptr<cCallbacks> cTCPLink::cCallbacksPtr

Definition at line 71 of file Network.h.

Constructor & Destructor Documentation

◆ ~cTCPLink()

virtual cTCPLink::~cTCPLink ( )
inlinevirtual

Definition at line 75 of file Network.h.

◆ cTCPLink()

cTCPLink::cTCPLink ( cCallbacksPtr  a_Callbacks)
inlineprotected

Creates a new link, with the specified callbacks.

Definition at line 143 of file Network.h.

Member Function Documentation

◆ Close()

virtual void cTCPLink::Close ( void  )
pure virtual

Drops the connection without any more processing.

Sends the RST packet, queued outgoing and incoming data is lost.

Implemented in cTCPLinkImpl.

◆ GetCallbacks()

cCallbacksPtr cTCPLink::GetCallbacks ( void  ) const
inline

Returns the callbacks that are used.

Definition at line 135 of file Network.h.

◆ GetLocalIP()

virtual AString cTCPLink::GetLocalIP ( void  ) const
pure virtual

Returns the IP address of the local endpoint of the connection.

Implemented in cTCPLinkImpl.

◆ GetLocalPort()

virtual UInt16 cTCPLink::GetLocalPort ( void  ) const
pure virtual

Returns the port used by the local endpoint of the connection.

Implemented in cTCPLinkImpl.

◆ GetRemoteIP()

virtual AString cTCPLink::GetRemoteIP ( void  ) const
pure virtual

Returns the IP address of the remote endpoint of the connection.

Implemented in cTCPLinkImpl.

◆ GetRemotePort()

virtual UInt16 cTCPLink::GetRemotePort ( void  ) const
pure virtual

Returns the port used by the remote endpoint of the connection.

Implemented in cTCPLinkImpl.

◆ Send() [1/2]

bool cTCPLink::Send ( const AString a_Data)
inline

Queues the specified data for sending to the remote peer.

Returns true on success, false on failure. Note that this success or failure only reports the queue status, not the actual data delivery.

Definition at line 83 of file Network.h.

◆ Send() [2/2]

virtual bool cTCPLink::Send ( const void *  a_Data,
size_t  a_Length 
)
pure virtual

Queues the specified data for sending to the remote peer.

Returns true on success, false on failure. Note that this success or failure only reports the queue status, not the actual data delivery.

Implemented in cTCPLinkImpl.

◆ Shutdown()

virtual void cTCPLink::Shutdown ( void  )
pure virtual

Closes the link gracefully.

The link will send any queued outgoing data, then it will send the FIN packet. The link will still receive incoming data from remote until the remote closes the connection.

Implemented in cTCPLinkImpl.

◆ StartTLSClient()

virtual AString cTCPLink::StartTLSClient ( cX509CertPtr  a_OwnCert,
cCryptoKeyPtr  a_OwnPrivKey,
cX509CertPtr  a_TrustedRootCAs 
)
pure virtual

Starts a TLS handshake as a client connection.

If a client certificate should be used for the connection, set the certificate into a_OwnCertData and its corresponding private key to a_OwnPrivKeyData. If both are empty, no client cert is presented. a_OwnPrivKeyPassword is the password to be used for decoding PrivKey, empty if not passworded. Returns empty string on success, non-empty error description on failure.

Implemented in cTCPLinkImpl.

◆ StartTLSServer()

virtual AString cTCPLink::StartTLSServer ( cX509CertPtr  a_OwnCert,
cCryptoKeyPtr  a_OwnPrivKey,
const AString a_StartTLSData 
)
pure virtual

Starts a TLS handshake as a server connection.

Set the server certificate into a_CertData and its corresponding private key to a_OwnPrivKeyData. a_OwnPrivKeyPassword is the password to be used for decoding PrivKey, empty if not passworded. a_StartTLSData is any data that should be pushed into the TLS before reading more data from the remote. This is used mainly for protocols starting TLS in the middle of communication, when the TLS start command can be received together with the TLS Client Hello message in one OnReceivedData() call, to re-queue the Client Hello message into the TLS handshake buffer. Returns empty string on success, non-empty error description on failure.

Implemented in cTCPLinkImpl.

Friends And Related Function Documentation

◆ cNetwork

friend class cNetwork
friend

Definition at line 43 of file Network.h.

Member Data Documentation

◆ m_Callbacks

cCallbacksPtr cTCPLink::m_Callbacks
protected

Callbacks to be used for the various situations.

Definition at line 139 of file Network.h.


The documentation for this class was generated from the following file: