Table Of Contents

Previous topic

ginsfsm.router

Next topic

ginsfsm.c_srv_sock

ginsfsm.c_sock

GObj GSock

GObj for manage socket events.

class ginsfsm.c_sock.GSock[source]

Client socket gobj.

Manage socket events.

Configurable Parameters:
Name Type Default value Description
close_when_flushed bool False True to close the socket when flushed
connected_event_name str EV_CONNECTED Must be empty if you don’t want receive this event
_socket_map None {} Set by gaplic. Dict {fd:Gobj}
_impl_poll None None Set by gaplic. epoll implementation
rx_data_event_name str EV_RX_DATA
ip str
outbuf_overflow int 1048576
host str server or client host (ip or name)
ports tuple () multi ports
subscriber None None subcriber of all output-events.Default is None, i.e., the parent
trace_dump bool False trace tx/rx messages
tx_buffer_size int 4096
disconnected_event_name str EV_DISCONNECTED Must be empty if you don’t want receive this event
send_bytes int 18000
use_multi_ports bool False use multi ports
n_gsocks int 0 Server Stats: Number of gsocks opened
transmit_ready_event_name str EV_TRANSMIT_READY Must be empty if you don’t want receive this event
port int 0 server or client port
ssl_options dict {} ssl options
addr None None Peername
Diagram:
Input-Events:
  • 'EV_SEND_DATA':

    Write data in the output data buffer and flush it right now.

    Equivalent to EV_WRITE_OUTPUT_DATA and EV_FLUSH_OUTPUT_DATA together.

    Event attributes:

    • data: data to send.
  • 'EV_WRITE_OUTPUT_DATA':

    Write data in the output data buffer.

    Event attributes:

    • data: data to send.
  • 'EV_FLUSH_OUTPUT_DATA':

    Flush the output buffer data.

Output-Events:
  • 'EV_CONNECTED': socket connected.

    Attributes added to the sent event:

    • peername: remote address to which the socket is connected.
    • sockname: the socket’s own address.
  • 'EV_DISCONNECTED': socket disconnected.

  • 'EV_TRANSMIT_READY': socket ready to transmit more data.

  • 'EV_RX_DATA': data received.

    The data is not buffered. As much data are read by recv() as data are broadcast.

    Event attributes:

    • data: Data received from remote address.
start_up()[source]

Initialization zone.

Subcribe all enabled output-event‘s to subscriber. By default the subscriber is the parent.

get_next_dst()[source]

Supply the destination (host,port) tuple to _mt_connect() method. By default this function returns the internal (host,port) attributes.

TO BE OVERRIDE if you need other policy.

get_peername()

Remote address to which the socket is connected

get_sockname()

the socket’s own address