plebble
us::gov::socket::client Class Reference

#include <client.h>

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

Classes

class  IPEndPoint
 
class  pair
 

Public Types

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

 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)
 
virtual pair< security_level_t, string > security_level () const
 
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
 
virtual void dump_all (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 ()
 
void ping ()
 
ko send1 (datagram d0)
 

Static Public Member Functions

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)
 

Public Attributes

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

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
 

Package Functions

String refdata ()
 
void set_finished ()
 

Package Attributes

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)
 

Private Member Functions

void dump_d (String prefix, datagram d, String addr)
 

Private Attributes

String addr
 
IPEndPoint remoteEndPoint
 
bool called_disconnect = false
 

Member Typedef Documentation

◆ queue_t

Member Enumeration Documentation

◆ security_level_t

Enumerator
security_level_ok 
security_level_disconnect 
security_level_ban 

Constructor & Destructor Documentation

◆ client() [1/6]

us::gov::socket::client::client ( )

◆ client() [2/6]

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

◆ ~client()

virtual us::gov::socket::client::~client ( )
virtual

◆ client() [3/6]

us.gov.socket.client.client ( )
inline

◆ client() [4/6]

us.gov.socket.client.client ( Socket  sock_)
inline

References addr, address, connected(), and sock.

Here is the call graph for this function:

◆ client() [5/6]

us.gov.socket.client.client ( )
inline

◆ client() [6/6]

us.gov.socket.client.client ( Socket  sock_)
inline

References activity, activity_recv, addr, address, connected(), last_test_alive, since, and sock.

Here is the call graph for this function:

Member Function Documentation

◆ address() [1/2]

String us.gov.socket.client.address ( )
inline

References remoteEndPoint.

◆ address() [2/2]

String us.gov.socket.client.address ( )
inline

References sock.

◆ age() [1/2]

static string us::gov::socket::client::age ( chrono::system_clock::time_point  time)
static

◆ age() [2/2]

static string us::gov::socket::client::age ( uint64_t  msts)
static

◆ connect0() [1/6]

ko us::gov::socket::client::connect0 ( const string &  host,
uint16_t  port,
bool  block 
)

◆ connect0() [2/6]

String us.gov.socket.client.connect0 ( String  host,
int  port 
)
inline

References connect0(), and port.

Here is the call graph for this function:

◆ connect0() [3/6]

String us.gov.socket.client.connect0 ( String  host,
int  port,
bool  block 
)
inline

References addr, called_disconnect, port, remoteEndPoint, sock, and us.gov.socket.client.IPEndPoint.TryParse().

Here is the call graph for this function:

◆ connect0() [4/6]

ko us.gov.socket.client.connect0 ( String  host,
uint16_t  hport,
boolean  block 
)
inline

◆ connect0() [5/6]

ko us.gov.socket.client.connect0 ( String  host,
uint16_t  port 
)
inline

References connect0(), and port.

Here is the call graph for this function:

◆ connect0() [6/6]

ko us::gov::socket::client::connect0 ( uint32_t  host,
uint16_t  port,
bool  block 
)

Referenced by connect0().

Here is the caller graph for this function:

◆ connected() [1/3]

bool us.gov.socket.client.connected ( )
inline

References called_disconnect, and sock.

◆ connected() [2/3]

boolean us.gov.socket.client.connected ( )
inline

References called_disconnect, and sock.

◆ connected() [3/3]

bool us::gov::socket::client::connected ( ) const
inline

◆ decrypt0() [1/2]

virtual pair<ko, datagram*> us::gov::socket::client::decrypt0 ( datagram d) const
virtual

Reimplemented in us::gov::id::peer_t.

Referenced by recv6().

Here is the caller graph for this function:

◆ decrypt0() [2/2]

pair<ko, datagram> us.gov.socket.client.decrypt0 ( final datagram  d)
inline

Reimplemented in us::gov::id::peer_t.

References us.ok.

◆ disconnect() [1/3]

◆ disconnect() [2/3]

virtual void us::gov::socket::client::disconnect ( uint16_t  seq,
const string &  reason 
)
virtual

◆ disconnect() [3/3]

void us.gov.socket.client.disconnect ( uint16_t  seq,
String  reason 
)
inline

◆ dump() [1/2]

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

◆ dump() [2/2]

void us.gov.socket.client.dump ( String  prefix,
PrintStream  os 
)
inline

◆ dump_all()

virtual void us::gov::socket::client::dump_all ( const string &  prefix,
ostream &  os 
) const
inlinevirtual

◆ dump_d()

void us.gov.socket.client.dump_d ( String  prefix,
datagram  d,
String  addr 
)
inlineprivate

◆ encrypt0() [1/2]

virtual pair<ko, datagram*> us::gov::socket::client::encrypt0 ( datagram d) const
virtual

Reimplemented in us::gov::id::peer_t.

Referenced by send1().

Here is the caller graph for this function:

◆ encrypt0() [2/2]

pair<ko, datagram> us.gov.socket.client.encrypt0 ( final datagram  d)
inline

Reimplemented in us::gov::id::peer_t.

References us.ok.

◆ endpoint() [1/6]

String us.gov.socket.client.endpoint ( )
inline

References addr, and endpoint().

Here is the call graph for this function:

◆ endpoint() [2/6]

string us::gov::socket::client::endpoint ( ) const

◆ endpoint() [3/6]

static string us::gov::socket::client::endpoint ( const pair< uint32_t, uint16_t > &  ip)
static

◆ endpoint() [4/6]

static String us.gov.socket.client.endpoint ( String  a,
uint16_t  p 
)
inlinestatic

◆ endpoint() [5/6]

static String us.gov.socket.client.endpoint ( uint32_t  a,
uint16_t  p 
)
inlinestatic

References ip4_decode().

Here is the call graph for this function:

◆ endpoint() [6/6]

static string us::gov::socket::client::endpoint ( uint32_t  addr,
uint16_t  port 
)
static

◆ host2addr()

static uint32_t us::gov::socket::client::host2addr ( const string &  host)
static

◆ init_sock2()

ko us::gov::socket::client::init_sock2 ( uint32_t  host,
uint16_t  port,
bool  block 
)

◆ ip4_decode() [1/2]

static string us::gov::socket::client::ip4_decode ( uint32_t  addr)
static

Referenced by us::gov::engine::auth::app::collusion_control_t::allow(), endpoint(), and us::gov::engine::auth::app::import().

Here is the caller graph for this function:

◆ ip4_decode() [2/2]

static String us.gov.socket.client.ip4_decode ( uint32_t  addr0)
inlinestatic

◆ ip4_encode() [1/2]

static uint32_t us::gov::socket::client::ip4_encode ( const string &  addr)
static

◆ ip4_encode() [2/2]

static uint32_t us.gov.socket.client.ip4_encode ( String  addr0)
inlinestatic

◆ is_finished() [1/2]

boolean us.gov.socket.client.is_finished ( )
inline

References finished.

◆ is_finished() [2/2]

bool us::gov::socket::client::is_finished ( ) const
inline

◆ is_valid_ip()

static bool us::gov::socket::client::is_valid_ip ( uint32_t  )
static

◆ is_wan_ip()

static bool us::gov::socket::client::is_wan_ip ( uint32_t  )
static

◆ IsConnected()

bool us.gov.socket.client.IsConnected ( )
inline

References sock.

◆ on_connect() [1/2]

void us.gov.socket.client.on_connect ( ko  err)
inline

◆ on_connect() [2/2]

virtual void us::gov::socket::client::on_connect ( ko  )
virtual

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

Referenced by us::gov::id::peer_t::connect(), and connect0().

Here is the caller graph for this function:

◆ parse_endpoint() [1/2]

static pair<ko,pair<string,uint16_t> > us::gov::socket::client::parse_endpoint ( const string &  ipport)
static

◆ parse_endpoint() [2/2]

static pair<ko, pair<String,Short> > us.gov.socket.client.parse_endpoint ( String  ipport)
inlinestatic

References KO_20190, KO_20191, and us.ok.

◆ ping() [1/2]

void us::gov::socket::client::ping ( )

◆ ping() [2/2]

void us.gov.socket.client.ping ( )
inline

Reimplemented in us::gov::socket::peer_t.

References us.gov.protocol.gov_socket_ping, and send1().

Here is the call graph for this function:

◆ prepare_worker_recv() [1/2]

void us::gov::socket::client::prepare_worker_recv ( )

◆ prepare_worker_recv() [2/2]

void us.gov.socket.client.prepare_worker_recv ( )
inline

References busyrecv.

◆ raddress()

pair<uint32_t,uint16_t> us::gov::socket::client::raddress ( ) const

◆ ready()

void us.gov.socket.client.ready ( )
inline

◆ recv3()

pair<String, datagram> us.gov.socket.client.recv3 ( )
inline

References disconnect(), us.gov.socket.client.pair< f, s >.first, us.gov.socket.client.pair< f, s >.second, and sock.

Here is the call graph for this function:

◆ recv4()

pair<String, datagram> us.gov.socket.client.recv4 ( datagram  d)
inline

References disconnect(), us.gov.socket.client.pair< f, s >.first, us.gov.socket.client.pair< f, s >.second, and sock.

Referenced by recv6().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recv4x() [1/2]

pair<ko,datagram*> us::gov::socket::client::recv4x ( datagram d)

Referenced by recv6().

Here is the caller graph for this function:

◆ recv4x() [2/2]

◆ recv6() [1/3]

pair<ko,datagram*> us::gov::socket::client::recv6 ( )

Referenced by us::gov::id::peer_t::run_auth_responder(), us::gov::cli::rpc_api::run_body(), and send_recv3().

Here is the caller graph for this function:

◆ recv6() [2/3]

pair<String, datagram> us.gov.socket.client.recv6 ( )
inline

References us.gov.socket.client.pair< f, s >.first, recv4(), and us.gov.socket.client.pair< f, s >.second.

Here is the call graph for this function:

◆ recv6() [3/3]

pair<ko, datagram> us.gov.socket.client.recv6 ( )
inline

◆ refdata() [1/2]

String us.gov.socket.client.refdata ( )
inlinepackage

References addr.

◆ refdata() [2/2]

string us::gov::socket::client::refdata ( ) const

◆ security_level()

virtual pair<security_level_t,string> us::gov::socket::client::security_level ( ) const
inlinevirtual

◆ send1() [1/2]

virtual ko us::gov::socket::client::send1 ( datagram )
virtual

◆ send1() [2/2]

◆ send3()

String us.gov.socket.client.send3 ( datagram  d)
inline

◆ send_recv3()

pair<String, datagram> us.gov.socket.client.send_recv3 ( datagram  d)
inline

References recv6(), and send3().

Referenced by us.wallet.rpc_api.sendrecv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_finished() [1/2]

void us::gov::socket::client::set_finished ( )

◆ set_finished() [2/2]

void us.gov.socket.client.set_finished ( )
inlinepackage

References finished.

◆ test_alive() [1/2]

void us::gov::socket::client::test_alive ( )

◆ test_alive() [2/2]

void us.gov.socket.client.test_alive ( )
inline

◆ worker_ended_recv() [1/2]

void us::gov::socket::client::worker_ended_recv ( )

◆ worker_ended_recv() [2/2]

void us.gov.socket.client.worker_ended_recv ( )
inline

References busyrecv.

Member Data Documentation

◆ activity [1/2]

atomic<uint64_t> us::gov::socket::client::activity

Referenced by client(), connect0(), recv4x(), and send1().

◆ activity [2/2]

AtomicLong us.gov.socket.client.activity =new AtomicLong(0L)
package

◆ activity_recv [1/2]

chrono::system_clock::time_point us::gov::socket::client::activity_recv

Referenced by client(), connect0(), and recv4x().

◆ activity_recv [2/2]

long us.gov.socket.client.activity_recv
package

◆ addr

String us.gov.socket.client.addr
private

Referenced by client(), connect0(), endpoint(), and refdata().

◆ address

uint32_t us::gov::socket::client::address

Referenced by client().

◆ busyled_recv

static busyled_t us::gov::socket::client::busyled_recv =new busyled_t()
static

Referenced by recv4x().

◆ busyrecv [1/2]

atomic<int> us::gov::socket::client::busyrecv {0}

◆ busyrecv [2/2]

AtomicInteger us.gov.socket.client.busyrecv =new AtomicInteger(0)
package

◆ called_disconnect [1/2]

bool us.gov.socket.client.called_disconnect = false
private

Referenced by connect0(), connected(), and disconnect().

◆ called_disconnect [2/2]

boolean us.gov.socket.client.called_disconnect =false
package

◆ finished [1/2]

◆ finished [2/2]

AtomicBoolean us.gov.socket.client.finished =new AtomicBoolean(false)
package

◆ finished_reason [1/2]

pair<uint16_t, string> us::gov::socket::client::finished_reason

Referenced by connect0(), and disconnect().

◆ finished_reason [2/2]

pair<uint16_t, String> us.gov.socket.client.finished_reason =new pair<uint16_t, String>(new uint16_t(0), "")
package

◆ KO_10100 [1/2]

const char * us::gov::socket::client::KO_10100
static

Referenced by connect0().

◆ KO_10100 [2/2]

final ko us.gov.socket.client.KO_10100 =new ko("KO 10100 Unreachable host.")
static

◆ KO_20190 [1/2]

const char * us::gov::socket::client::KO_20190
static

Referenced by parse_endpoint().

◆ KO_20190 [2/2]

final ko us.gov.socket.client.KO_20190 =new ko("KO 20190 Invalid endpoint port.")
static

◆ KO_20191 [1/2]

const char * us::gov::socket::client::KO_20191
static

Referenced by parse_endpoint().

◆ KO_20191 [2/2]

final ko us.gov.socket.client.KO_20191 =new ko("KO 20191 Invalid endpoint host.")
static

◆ KO_58961 [1/2]

const char * us::gov::socket::client::KO_58961
static

◆ KO_58961 [2/2]

final ko us.gov.socket.client.KO_58961 =new ko("KO 58961 Invalid port.")
static

◆ KO_60541

const char * us::gov::socket::client::KO_60541
static

◆ KO_7190

const char* us::gov::socket::client::KO_7190
static

◆ KO_83911

final ko us.gov.socket.client.KO_83911 =new ko("KO 83911 IO Exception.")
static

Referenced by connect0().

◆ KO_83912

final ko us.gov.socket.client.KO_83912 =new ko("KO 83912 Exception.")
static

Referenced by connect0().

◆ last_test_alive [1/2]

chrono::system_clock::time_point us::gov::socket::client::last_test_alive

Referenced by client(), and connect0().

◆ last_test_alive [2/2]

long us.gov.socket.client.last_test_alive
package

◆ parent

server* us::gov::socket::client::parent {nullptr}

◆ port

uint16_t us::gov::socket::client::port

◆ prev_uid

long us.gov.socket.client.prev_uid =0
static

◆ remoteEndPoint

IPEndPoint us.gov.socket.client.remoteEndPoint
private

Referenced by address(), and connect0().

◆ sendq [1/2]

◆ sendq [2/2]

send_queue us.gov.socket.client.sendq =null

◆ sendref [1/2]

atomic<int> us::gov::socket::client::sendref {0}

Referenced by send1().

◆ sendref [2/2]

AtomicInteger us.gov.socket.client.sendref =new AtomicInteger(0)

◆ since [1/2]

chrono::system_clock::time_point us::gov::socket::client::since

◆ since [2/2]

long us.gov.socket.client.since

◆ sock [1/2]

◆ sock [2/2]

Socket us.gov.socket.client.sock =null

◆ timeout

struct timeval us::gov::socket::client::timeout
static

◆ uid

long us.gov.socket.client.uid =++prev_uid

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