Protocol facet to support TCP operations. More...

#include <senf/Socket/Protocols/INet/TCPSocketProtocol.hh>

Inheritance diagram for senf::TCPSocketProtocol:

Public Types

enum  ShutType { ShutRD, ShutWR, ShutRDWR }
 

Public Member Functions

bool nodelay () const
 Check current SO_NODELAY status. More...
 
void nodelay (bool value) const
 Set SO_NODELAY status. More...
 
unsigned siocinq () const
 Return current size of the input queue. More...
 
unsigned siocoutq () const
 Return current size of the output queue. More...
 
void shutdown (ShutType type) const
 
- Public Member Functions inherited from senf::INetSocketProtocol
void bindInterface (std::string const &iface) const
 Bind socket to specific interface. More...
 
std::string bindInterface ()
 Get bound interface. More...
 
- Public Member Functions inherited from senf::SocketProtocol
virtual SocketPolicyBase const & policy () const =0
 Access the policy instance. 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
 

Abstract Interface Implementation

void close ()
 Close socket. More...
 
unsigned available () const
 Return (maximum) number of bytes available for reading without < blocking. More...
 
bool eof () const
 Check for end-of-file condition. More...
 

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 to support TCP operations.

This protocol facet provides all those protocol functions, which are available on any TCP socket.

Definition at line 37 of file TCPSocketProtocol.hh.

Member Enumeration Documentation

◆ ShutType

Enumerator
ShutRD 
ShutWR 
ShutRDWR 

Definition at line 53 of file TCPSocketProtocol.hh.

Member Function Documentation

◆ available()

unsigned senf::TCPSocketProtocol::available ( ) const
virtual

Return (maximum) number of bytes available for reading without < blocking.

This member will check in a (very, sigh) protocol dependent way, how many bytes may be read from a socket in a single (non-blocking) read operation. If the socket does not support reading (viz. NotReadablePolicy is set), this member should always return 0.

Depending on the protocol, it may not be possible to return a good value. In this case, an upper bound may be returned (e.g.: When reading from a socket which returns ethernet frames, returning 1500 from available() is ok). However, this should only be done as a last resort. Also beware, that this number should not be too large since the socket layer will always need to allocate that number of bytes for the data to be read.

Implements senf::SocketProtocol.

Definition at line 81 of file TCPSocketProtocol.cc.

◆ close()

void senf::TCPSocketProtocol::close ( )
virtual

Close socket.

This override will automatically shutdown() the socket whenever it is closed.

Exceptions
senf::SystemException
Fix:
Move into (at least) BSDSOcketProtocol

Reimplemented from senf::SocketProtocol.

Definition at line 75 of file TCPSocketProtocol.cc.

◆ eof()

bool senf::TCPSocketProtocol::eof ( ) const
virtual

Check for end-of-file condition.

This is another check which (like available()) is extremely protocol dependent. This member will return true only, if at end-of-file. If the protocol does not support the notion of EOF, this member should always return false.

Implements senf::SocketProtocol.

Definition at line 87 of file TCPSocketProtocol.cc.

◆ nodelay() [1/2]

bool senf::TCPSocketProtocol::nodelay ( ) const

Check current SO_NODELAY status.

Definition at line 32 of file TCPSocketProtocol.cc.

◆ nodelay() [2/2]

void senf::TCPSocketProtocol::nodelay ( bool  value) const

Set SO_NODELAY status.

Enabling SO_NODELAY will disable the NAGLE algorithm (which aggregates multiple writes into a single network packet). Enabling nodelay() optimizes the response time at the expense of the bandwidth efficiency.

Parameters
[in]valueSO_NODELAY state

Definition at line 42 of file TCPSocketProtocol.cc.

◆ shutdown()

void senf::TCPSocketProtocol::shutdown ( ShutType  type) const

Definition at line 68 of file TCPSocketProtocol.cc.

◆ siocinq()

unsigned senf::TCPSocketProtocol::siocinq ( ) const

Return current size of the input queue.

Definition at line 50 of file TCPSocketProtocol.cc.

◆ siocoutq()

unsigned senf::TCPSocketProtocol::siocoutq ( ) const

Return current size of the output queue.

Definition at line 59 of file TCPSocketProtocol.cc.


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