libfilezilla
Public Member Functions | List of all members
ascii_layer Class Referencefinal

#include <ascii_layer.hpp>

Inheritance diagram for ascii_layer:
Inheritance graph
[legend]
Collaboration diagram for ascii_layer:
Collaboration graph
[legend]

Public Member Functions

 ascii_layer (event_loop &loop, event_handler *handler, socket_interface &next_layer)
 
virtual int read (void *buffer, unsigned int size, int &error) override
 
virtual int write (void const *buffer, unsigned int size, int &error) override
 
virtual int shutdown () override
 Signals peers that we want to close the connections. More...
 
virtual void set_event_handler (event_handler *handler, fz::socket_event_flag retrigger_block=fz::socket_event_flag{}) override
 The handler for any events generated (or forwarded) by this layer.
 
- Public Member Functions inherited from socket_layer
 socket_layer (event_handler *handler, socket_interface &next_layer, bool event_passthrough)
 
 socket_layer (socket_layer const &)=delete
 
socket_layeroperator= (socket_layer const &)=delete
 
virtual native_string peer_host () const override
 
virtual int peer_port (int &error) const override
 
socket_interfacenext ()
 The next layer further down. Usually another layer or the actual socket.
 
virtual int shutdown_read () override
 Check that all layers further down also have reached EOF. More...
 
virtual int connect (native_string const &host, unsigned int port, address_type family=address_type::unknown) override
 
virtual socket_state get_state () const override
 
- Public Member Functions inherited from socket_interface
 socket_interface (socket_interface const &)=delete
 
socket_interfaceoperator= (socket_interface const &)=delete
 
template<typename T , std::enable_if_t< std::is_signed_v< T >, int > = 0>
int read (void *buffer, T size, int &error)
 
template<typename T , std::enable_if_t< std::is_unsigned_v< T > &&(sizeof(T) > sizeof(unsigned int)), int > = 0>
int read (void *buffer, T size, int &error)
 
template<typename T , std::enable_if_t< std::is_signed_v< T >, int > = 0>
int write (void const *buffer, T size, int &error)
 
template<typename T , std::enable_if_t< std::is_unsigned_v< T > &&(sizeof(T) > sizeof(unsigned int)), int > = 0>
int write (void const *buffer, T size, int &error)
 
- Public Member Functions inherited from socket_event_source
socket_event_sourceroot () const
 Gets the root source. More...
 

Additional Inherited Members

- Protected Member Functions inherited from socket_layer
void forward_socket_event (socket_event_source *source, socket_event_flag t, int error)
 
void forward_hostaddress_event (socket_event_source *source, std::string const &address)
 
void set_event_passthrough (socket_event_flag retrigger_block=socket_event_flag{})
 
- Protected Member Functions inherited from socket_interface
 socket_interface (socket_event_source *root)
 
- Protected Member Functions inherited from socket_event_source
 socket_event_source (socket_event_source *root)
 
- Protected Member Functions inherited from event_handler
 event_handler (event_loop &loop)
 
 event_handler (event_handler const &h)
 
event_handleroperator= (event_handler const &)=delete
 
void remove_handler ()
 Deactivates handler, removes all pending events and stops all timers for this handler. More...
 
template<typename T , typename... Args>
void send_event (Args &&... args)
 Sends the passed event asynchronously to the handler. More...
 
template<typename T >
void send_event (T *evt)
 
timer_id add_timer (monotonic_clock const &deadline, duration const &interval={})
 Adds a timer, returns the timer id. More...
 
timer_id add_timer (duration const &interval, bool one_shot)
 Adds a timer, returns the timer id. More...
 
void stop_timer (timer_id id)
 
timer_id stop_add_timer (timer_id id, monotonic_clock const &deadline, duration const &interval={})
 
timer_id stop_add_timer (timer_id id, duration const &interval, bool one_shot)
 
- Protected Attributes inherited from socket_layer
event_handlerevent_handler_ {}
 
socket_interfacenext_layer_
 
bool event_passthrough_ {}
 
- Protected Attributes inherited from socket_event_source
socket_event_source *const root_ {}
 
- Protected Attributes inherited from event_handler
event_loopevent_loop_
 

Detailed Description

A socket layer that transforms between line endings.

When sending, LF not preceeded by CR is converted into CRLF. Stray CRs are kept. When receiving, CRs followed by LF are removed. As with sending, stray CRs ar kept.

Member Function Documentation

◆ shutdown()

virtual int shutdown ( )
overridevirtual

Signals peers that we want to close the connections.

Only disallows further sends, does not affect reading from the socket.

Returns 0 on success, an error code otherwise. If it returns EGAIN, shutdown is not yet complete. Call shutdown again after the next write event.

Reimplemented from socket_layer.


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