libfilezilla
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
socket_base Class Reference

Common base clase for fz::socket and fz::listen_socket. More...

#include <socket.hpp>

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

Public Types

typedef intptr_t socket_t
 

Public Member Functions

int set_buffer_sizes (int size_receive, int size_send)
 Sets socket buffer sizes. More...
 
address_type address_family () const
 If connected, either ipv4, ipv6 or unix, unknown otherwise.
 
std::string local_ip (bool strip_zone_index=false) const
 Returns local address of a connected socket. More...
 
int local_port (int &error) const
 Returns local port of a connected socket. More...
 
bool bind (std::string const &address)
 Bind socket to the specific local IP. More...
 

Static Public Member Functions

static std::string address_to_string (sockaddr const *addr, int addr_len, bool with_port=true, bool strip_zone_index=false)
 
static std::string address_to_string (char const *buf, int buf_len)
 

Protected Member Functions

 socket_base (thread_pool &pool, event_handler *evt_handler, socket_event_source *ev_source)
 
int close ()
 
void detach_thread (scoped_lock &l)
 

Protected Attributes

thread_poolthread_pool_
 
event_handlerevt_handler_
 
socket_thread * socket_thread_ {}
 
socket_event_source *const ev_source_ {}
 
socket_t fd_ {-1}
 
unsigned int port_ {}
 
int family_
 
int buffer_sizes_ [2]
 

Friends

class socket_thread
 

Detailed Description

Common base clase for fz::socket and fz::listen_socket.

Member Function Documentation

◆ bind()

bool bind ( std::string const &  address)

Bind socket to the specific local IP.

Undefined after having called connect/listen

◆ local_ip()

std::string local_ip ( bool  strip_zone_index = false) const

Returns local address of a connected socket.

Returns
empty string on error

◆ local_port()

int local_port ( int &  error) const

Returns local port of a connected socket.

Returns
-1 on error

◆ set_buffer_sizes()

int set_buffer_sizes ( int  size_receive,
int  size_send 
)

Sets socket buffer sizes.

Internally this sets SO_RCVBUF and SO_SNDBUF on the socket.

If called on listen socket, sizes will be inherited by accepted sockets.


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