Protocol facet providing basic BSD socket functionality. More...

#include <senf/Socket/Protocols/BSDSocketProtocol.hh>

Inherits senf::SocketProtocol.

Inherited by senf::ConnectedRawV4SocketProtocol, senf::ConnectedRawV6SocketProtocol, senf::ConnectedUDPv4SocketProtocol, senf::ConnectedUDPv6SocketProtocol, senf::ConnectedUNDatagramSocketProtocol, senf::PacketSocketProtocol, senf::RawV4SocketProtocol, senf::RawV6SocketProtocol, senf::TapSocketProtocol, senf::TCPv4SocketProtocol, senf::TCPv6SocketProtocol, senf::UDPv4SocketProtocol, senf::UDPv6SocketProtocol, and senf::UNDatagramSocketProtocol.

Public Member Functions

std::pair< bool, unsigned > linger () const
 Return current linger status. More...
 
void linger (bool enable, unsigned timeout=0) const
 Change linger status. More...
 
boost::uint8_t priority () const
 Get packet priority assigned to outgoing packets. More...
 
void priority (boost::uint8_t value) const
 Set packet priority (e.g. TOS) More...
 
int error () const
 Get and clear pending socket error. More...
 
unsigned rcvbuf () const
 Check receive buffer size. More...
 
void rcvbuf (unsigned size) const
 Change receive buffer size. More...
 
unsigned sndbuf () const
 Check send buffer size. More...
 
void sndbuf (unsigned size) const
 Change size of send buffer. More...
 
template<unsigned short N>
void attachSocketFilter (::sock_filter(&filter)[N])
 
void detachSocketFilter ()
 
void mtuDiscovery (int mode) const
 
void rcvLowat (unsigned lowWat) const
 
void sndLowat (unsigned lowWat) const
 
- Public Member Functions inherited from senf::SocketProtocol
virtual SocketPolicyBase const & policy () const =0
 Access the policy instance. More...
 
virtual unsigned available () const =0
 Return (maximum) number of bytes available for reading without < blocking. More...
 
virtual bool eof () const =0
 Check for end-of-file condition. More...
 
virtual void close ()
 Close socket. More...
 
virtual void terminate () const
 Forcibly close socket. More...
 
virtual void state (SocketStateMap &map, unsigned lod) const
 Return socket state information. More...
 
int fd () const
 Get file descriptor. More...
 
 SocketProtocol ()
 
virtual ~SocketProtocol ()=0
 

Additional Inherited Members

- Protected Member Functions inherited from senf::SocketProtocol
FileHandle fh () const
 Get a FileHandle for this instance. More...
 
void fd (int) const
 Initialize file descriptor. More...
 

Detailed Description

Protocol facet providing basic BSD socket functionality.

BSDSocketProtocol provides the basic BSD socket API as shared by all BSD sockets.

Definition at line 37 of file BSDSocketProtocol.hh.

Member Function Documentation

◆ attachSocketFilter()

template<unsigned short N>
void senf::BSDSocketProtocol::attachSocketFilter ( ::sock_filter(&)  filter[N])

◆ detachSocketFilter()

void senf::BSDSocketProtocol::detachSocketFilter ( )

Definition at line 120 of file BSDSocketProtocol.cc.

◆ error()

int senf::BSDSocketProtocol::error ( ) const

Get and clear pending socket error.

This call will get and clear a pending socket error. This includes asynchronous errors received via the network (e.g. via ICMP).

Definition at line 72 of file BSDSocketProtocol.cc.

◆ linger() [1/2]

std::pair< bool, unsigned > senf::BSDSocketProtocol::linger ( ) const

Return current linger status.

The value is returned in an std:pair. the first element is true, if linger is active. The second value is the linger timeout in seconds.

Returns
linger state (enable disabled) and linger timeout

Definition at line 33 of file BSDSocketProtocol.cc.

◆ linger() [2/2]

void senf::BSDSocketProtocol::linger ( bool  enable,
unsigned  timeout = 0 
) const

Change linger status.

If linger is enabled, the timeout value specifies, how long to wait before returning while data is unsent in seconds. If this value is 0, a close() might wait forever.

Parameters
[in]enabletrue to activate linger
[in]timeoutlinger timeout in seconds

Definition at line 44 of file BSDSocketProtocol.cc.

◆ mtuDiscovery()

void senf::BSDSocketProtocol::mtuDiscovery ( int  mode) const

Definition at line 136 of file BSDSocketProtocol.cc.

◆ priority() [1/2]

boost::uint8_t senf::BSDSocketProtocol::priority ( ) const

Get packet priority assigned to outgoing packets.

This call will return the priority value assigned to packets sent via this socket. Depending on the protocol, this value may also be placed inside the packet headers (for IPv4, this is the TOS value).

Returns
current socket priority

Definition at line 54 of file BSDSocketProtocol.cc.

◆ priority() [2/2]

void senf::BSDSocketProtocol::priority ( boost::uint8_t  value) const

Set packet priority (e.g. TOS)

Changes the packet queueing priority. Additionally may set protocol specific options. For IPv4 sockets, it sets the TOS field.

Parameters
[in]valuenew socket priority

Definition at line 64 of file BSDSocketProtocol.cc.

◆ rcvbuf() [1/2]

unsigned senf::BSDSocketProtocol::rcvbuf ( ) const

Check receive buffer size.

Returns
size of receive buffer in bytes

Linux doubles the buffer size internally when changing it to cater for additional space needed by the linux kernel. This call will therefore return only half the value reported by the kernel.

Definition at line 82 of file BSDSocketProtocol.cc.

◆ rcvbuf() [2/2]

void senf::BSDSocketProtocol::rcvbuf ( unsigned  size) const

Change receive buffer size.

Parameters
[in]sizenew receive buffer size

Definition at line 94 of file BSDSocketProtocol.cc.

◆ rcvLowat()

void senf::BSDSocketProtocol::rcvLowat ( unsigned  lowWat) const

Definition at line 150 of file BSDSocketProtocol.cc.

◆ sndbuf() [1/2]

unsigned senf::BSDSocketProtocol::sndbuf ( ) const

Check send buffer size.

Returns
size of send buffer in bytes

Linux doubles the buffer size internally when changing it to cater for additional space needed by the linux kernel. This call will therefore return only half the value reported by the kernel.

Definition at line 101 of file BSDSocketProtocol.cc.

◆ sndbuf() [2/2]

void senf::BSDSocketProtocol::sndbuf ( unsigned  size) const

Change size of send buffer.

Parameters
[in]sizenew send buffer size

Definition at line 113 of file BSDSocketProtocol.cc.

◆ sndLowat()

void senf::BSDSocketProtocol::sndLowat ( unsigned  lowWat) const

Definition at line 143 of file BSDSocketProtocol.cc.


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