plebble
us::gov::socket::peer_t Class Reference

#include <peer_t.h>

Inheritance diagram for us::gov::socket::peer_t:
Collaboration diagram for us::gov::socket::peer_t:

Public Types

typedef client b
 
- Public Types inherited from us::gov::socket::client
enum  security_level_t { security_level_ok, security_level_disconnect, security_level_ban }
 
typedef us::gov::socket::send_queue_t queue_t
 

Public Member Functions

 peer_t ()
 
 peer_t (int sock)
 
 peer_t (const peer_t &)=delete
 
peer_toperator= (const peer_t &)=delete
 
 ~peer_t () override
 
void dump_all (const string &prefix, ostream &os) const override
 
pair< security_level_t, string > security_level () const override
 
bool stalled_datagram () const
 
bool process_work (datagram *d)
 
void dump (const string &prefix, ostream &os) const
 
virtual void on_peer_disconnected (const string &reason)
 
 peer_t ()
 
 peer_t (Socket sock)
 
bool is_slow ()
 
bool ping ()
 
void process_pong ()
 
virtual bool process_work (datagram d)
 
 peer_t ()
 
 peer_t (Socket sock)
 
boolean process_work (datagram d)
 
void on_peer_disconnected (String reason)
 
- Public Member Functions inherited from us::gov::socket::client
 client ()
 
 client (int sock)
 
virtual ~client ()
 
ko connect0 (uint32_t host, uint16_t port, bool block)
 
ko connect0 (const string &host, uint16_t port, bool block)
 
virtual void disconnect (uint16_t seq, const string &reason)
 
bool connected () const
 
pair< uint32_t, uint16_t > raddress () const
 
virtual pair< ko, datagram * > encrypt0 (datagram *d) const
 
virtual pair< ko, datagram * > decrypt0 (datagram *d) const
 
virtual void on_connect (ko)
 
pair< ko, datagram * > recv4x (datagram *d)
 
pair< ko, datagram * > recv6 ()
 
ko init_sock2 (uint32_t host, uint16_t port, bool block)
 
void dump (const string &prefix, ostream &os) const
 
string refdata () const
 
string endpoint () const
 
virtual ko send1 (datagram *)
 
void prepare_worker_recv ()
 
void worker_ended_recv ()
 
void set_finished ()
 
bool is_finished () const
 
void test_alive ()
 
void ping ()
 
 client ()
 
 client (Socket sock_)
 
String connect0 (String host, int port)
 
String connect0 (String host, int port, bool block)
 
void disconnect ()
 
bool connected ()
 
bool IsConnected ()
 
String address ()
 
void ready ()
 
pair< String, datagramsend_recv3 (datagram d)
 
pair< String, datagramrecv6 ()
 
pair< String, datagramrecv3 ()
 
pair< String, datagramrecv4 (datagram d)
 
String send3 (datagram d)
 
 client ()
 
 client (Socket sock_)
 
void prepare_worker_recv ()
 
void worker_ended_recv ()
 
void on_connect (ko err)
 
ko connect0 (String host, uint16_t port)
 
ko connect0 (String host, uint16_t hport, boolean block)
 
void disconnect (uint16_t seq, String reason)
 
boolean connected ()
 
String address ()
 
String endpoint ()
 
pair< ko, datagramrecv6 ()
 
pair< ko, datagramrecv4x (datagram d)
 
boolean is_finished ()
 
pair< ko, datagramencrypt0 (final datagram d)
 
pair< ko, datagramdecrypt0 (final datagram d)
 
void dump (String prefix, PrintStream os)
 
void test_alive ()
 
ko send1 (datagram d0)
 

Public Attributes

datagramcurd {nullptr}
 
mutex mx_curd
 
- Public Attributes inherited from us::gov::socket::client
chrono::system_clock::time_point since
 
chrono::system_clock::time_point activity_recv
 
chrono::system_clock::time_point last_test_alive
 
atomic< uint64_t > activity
 
atomic< int > busyrecv {0}
 
int sock =null
 
uint32_t address
 
uint16_t port
 
atomic< int > sendref {0}
 
serverparent {nullptr}
 
queue_tsendq {nullptr}
 
pair< uint16_t, string > finished_reason
 
atomic< bool > finished {false}
 
Socket sock =null
 
long since
 
send_queue sendq =null
 
AtomicInteger sendref =new AtomicInteger(0)
 
long uid =++prev_uid
 

Static Public Attributes

constexpr static chrono::seconds stall {5s}
 
static const char * finished_reason_1
 
static const char * finished_reason_2
 
- Static Public Attributes inherited from us::gov::socket::client
static const char * KO_7190
 
static const char * KO_58961
 
static const char * KO_60541
 
static const char * KO_10100
 
static const char * KO_20190
 
static const char * KO_20191
 
static busyled_t busyled_recv =new busyled_t()
 
static struct timeval timeout
 
static final ko KO_58961 =new ko("KO 58961 Invalid port.")
 
static final ko KO_83911 =new ko("KO 83911 IO Exception.")
 
static final ko KO_83912 =new ko("KO 83912 Exception.")
 
static final ko KO_10100 =new ko("KO 10100 Unreachable host.")
 
static final ko KO_20190 =new ko("KO 20190 Invalid endpoint port.")
 
static final ko KO_20191 =new ko("KO 20191 Invalid endpoint host.")
 
static long prev_uid =0
 

Additional Inherited Members

- Static Public Member Functions inherited from us::gov::socket::client
static uint32_t host2addr (const string &host)
 
static string age (uint64_t msts)
 
static string age (chrono::system_clock::time_point time)
 
static string ip4_decode (uint32_t addr)
 
static uint32_t ip4_encode (const string &addr)
 
static bool is_wan_ip (uint32_t)
 
static bool is_valid_ip (uint32_t)
 
static string endpoint (uint32_t addr, uint16_t port)
 
static string endpoint (const pair< uint32_t, uint16_t > &ip)
 
static pair< ko, pair< string, uint16_t > > parse_endpoint (const string &ipport)
 
static pair< ko, pair< String, Short > > parse_endpoint (String ipport)
 
static String ip4_decode (uint32_t addr0)
 
static uint32_t ip4_encode (String addr0)
 
static String endpoint (uint32_t a, uint16_t p)
 
static String endpoint (String a, uint16_t p)
 
- Package Functions inherited from us::gov::socket::client
String refdata ()
 
void set_finished ()
 
- Package Attributes inherited from us::gov::socket::client
pair< uint16_t, String > finished_reason =new pair<uint16_t, String>(new uint16_t(0), "")
 
AtomicBoolean finished =new AtomicBoolean(false)
 
AtomicInteger busyrecv =new AtomicInteger(0)
 
boolean called_disconnect =false
 
long activity_recv
 
long last_test_alive
 
AtomicLong activity =new AtomicLong(0L)
 

Member Typedef Documentation

◆ b

Constructor & Destructor Documentation

◆ peer_t() [1/7]

us::gov::socket::peer_t::peer_t ( )

◆ peer_t() [2/7]

us::gov::socket::peer_t::peer_t ( int  sock)

◆ peer_t() [3/7]

us::gov::socket::peer_t::peer_t ( const peer_t )
delete

◆ ~peer_t()

us::gov::socket::peer_t::~peer_t ( )
override

◆ peer_t() [4/7]

us.gov.socket.peer_t.peer_t ( )
inline

◆ peer_t() [5/7]

us.gov.socket.peer_t.peer_t ( Socket  sock)
inline

◆ peer_t() [6/7]

us.gov.socket.peer_t.peer_t ( )
inline

◆ peer_t() [7/7]

us.gov.socket.peer_t.peer_t ( Socket  sock)
inline

Member Function Documentation

◆ dump()

void us::gov::socket::peer_t::dump ( const string &  prefix,
ostream &  os 
) const

◆ dump_all()

void us::gov::socket::peer_t::dump_all ( const string &  prefix,
ostream &  os 
) const
overridevirtual

Reimplemented from us::gov::socket::client.

◆ is_slow()

bool us.gov.socket.peer_t.is_slow ( )
inline

◆ on_peer_disconnected() [1/2]

virtual void us::gov::socket::peer_t::on_peer_disconnected ( const string &  reason)
virtual

Reimplemented in us::gov::cli::rpc_api, and us::gov::cli::hmi::rpc_api.

Referenced by process_work().

Here is the caller graph for this function:

◆ on_peer_disconnected() [2/2]

void us.gov.socket.peer_t.on_peer_disconnected ( String  reason)
inline

Reimplemented in us.wallet.daemon.rpc_api.endpoint_t, and us::gov::cli::rpc_api.

References us::gov::socket::client.disconnect().

Here is the call graph for this function:

◆ operator=()

peer_t& us::gov::socket::peer_t::operator= ( const peer_t )
delete

◆ ping()

bool us.gov.socket.peer_t.ping ( )
inline

Reimplemented from us::gov::socket::client.

References us.gov.protocol.gov_socket_ping, and us::gov::socket::client.send3().

Here is the call graph for this function:

◆ process_pong()

void us.gov.socket.peer_t.process_pong ( )
inline

Referenced by process_work().

Here is the caller graph for this function:

◆ process_work() [1/3]

bool us::gov::socket::peer_t::process_work ( datagram d)

◆ process_work() [2/3]

virtual bool us.gov.socket.peer_t.process_work ( datagram  d)
inlinevirtual

◆ process_work() [3/3]

◆ security_level()

pair<security_level_t,string> us::gov::socket::peer_t::security_level ( ) const
overridevirtual

Reimplemented from us::gov::socket::client.

◆ stalled_datagram()

bool us::gov::socket::peer_t::stalled_datagram ( ) const

Member Data Documentation

◆ curd

datagram* us::gov::socket::peer_t::curd {nullptr}

◆ finished_reason_1

const char* us::gov::socket::peer_t::finished_reason_1
static

◆ finished_reason_2

const char* us::gov::socket::peer_t::finished_reason_2
static

◆ mx_curd

mutex us::gov::socket::peer_t::mx_curd
mutable

◆ stall

constexpr static chrono::seconds us::gov::socket::peer_t::stall {5s}
staticconstexpr

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