E-MailRelay
Public Member Functions | List of all members
GNet::RawSocket Class Reference

A derivation of GNet::SocketBase for a raw socket, typically of type AF_NETLINK or PF_ROUTE. More...

#include <gsocket.h>

+ Inheritance diagram for GNet::RawSocket:
+ Collaboration diagram for GNet::RawSocket:

Public Member Functions

 RawSocket (int domain, int type, int protocol)
 Constructor. More...
 
ssize_type read (char *buffer, size_type buffer_length) override
 Reads from the socket. More...
 
ssize_type write (const char *buf, size_type len) override
 Writes to the socket. More...
 
 RawSocket (const RawSocket &)=delete
 
 RawSocket (RawSocket &&)=delete
 
RawSocketoperator= (const RawSocket &)=delete
 
RawSocketoperator= (RawSocket &&)=delete
 
- Public Member Functions inherited from GNet::SocketBase
 ~SocketBase () override
 Destructor. More...
 
SOCKET fd () const noexcept override
 Returns the socket file descriptor. More...
 
Descriptor fdd () const noexcept
 Returns the socket descriptor. More...
 
bool eWouldBlock () const override
 Returns true if the previous socket operation failed because the socket would have blocked. More...
 
bool eInProgress () const
 Returns true if the previous socket operation failed with the EINPROGRESS error status. More...
 
bool eInUse () const
 Returns true if the previous socket bind operation failed because the socket was already in use. More...
 
bool eMsgSize () const
 Returns true if the previous socket operation failed with the EMSGSIZE error status. More...
 
bool eTooMany () const
 Returns true if the previous socket operation failed with the EMFILE error status, or similar. More...
 
bool eNotConn () const
 Returns true if the previous socket operation failed with the ENOTCONN error status, or similar. More...
 
void addReadHandler (EventHandler &, EventState)
 Adds this socket to the event source list so that the given handler receives read events. More...
 
void dropReadHandler () noexcept
 Reverses addReadHandler(). More...
 
void addWriteHandler (EventHandler &, EventState)
 Adds this socket to the event source list so that the given handler receives write events when flow control is released. More...
 
void dropWriteHandler () noexcept
 Reverses addWriteHandler(). More...
 
void addOtherHandler (EventHandler &, EventState)
 Adds this socket to the event source list so that the given handler receives exception events. More...
 
void dropOtherHandler () noexcept
 Reverses addOtherHandler(). More...
 
std::string asString () const
 Returns the socket handle as a string. More...
 
std::string reason () const
 Returns the reason for the previous error. More...
 
 SocketBase (const SocketBase &)=delete
 
 SocketBase (SocketBase &&)=delete
 
SocketBaseoperator= (const SocketBase &)=delete
 
SocketBaseoperator= (SocketBase &&)=delete
 
- Public Member Functions inherited from G::ReadWrite
virtual ssize_type read (char *buffer, size_type buffer_length)=0
 Reads data. More...
 
virtual ssize_type write (const char *buf, size_type len)=0
 Sends data. More...
 
virtual bool eWouldBlock () const =0
 See read() and write(). More...
 
virtual SOCKET fd () const noexcept=0
 Returns the file descriptor. More...
 
virtual ~ReadWrite ()=default
 Destructor.
 

Additional Inherited Members

- Public Types inherited from GNet::SocketBase
using size_type = G::ReadWrite::size_type
 
using ssize_type = G::ReadWrite::ssize_type
 
- Public Types inherited from G::ReadWrite
using size_type = std::size_t
 
using ssize_type = ssize_t
 
- Static Public Member Functions inherited from GNet::SocketBase
static bool supports (Address::Family, int type, int protocol)
 Returns true if sockets can be created with the given parameters. More...
 
- Protected Member Functions inherited from GNet::SocketBase
 SocketBase (Address::Family, int type, int protocol)
 Constructor used by derived classes. More...
 
 SocketBase (Address::Family, Descriptor s)
 Constructor used by derived classes. More...
 
 SocketBase (Address::Family, Descriptor s, const Accepted &)
 Constructor used by StreamSocket::accept() to create a socket object from a newly accept()ed socket handle. More...
 
 SocketBase (const Raw &, int domain, int type, int protocol)
 Constructor for a raw socket. More...
 
void clearReason ()
 Clears the saved errno. More...
 
void saveReason ()
 Saves the current errno following error()/sizeError(). More...
 
void saveReason () const
 Saves the current errno following error()/sizeError(). More...
 
bool isFamily (Address::Family) const
 Returns true if the socket family is as given. More...
 
- Static Protected Member Functions inherited from GNet::SocketBase
static bool error (int rc)
 Returns true if the given return code indicates an error. More...
 
static bool sizeError (ssize_type size)
 Returns true if the given write() return value indicates an error. More...
 

Detailed Description

A derivation of GNet::SocketBase for a raw socket, typically of type AF_NETLINK or PF_ROUTE.

Definition at line 484 of file gsocket.h.

Constructor & Destructor Documentation

◆ RawSocket()

GNet::RawSocket::RawSocket ( int  domain,
int  type,
int  protocol 
)

Constructor.

Definition at line 218 of file gsocket_unix.cpp.

Member Function Documentation

◆ read()

GNet::SocketBase::ssize_type GNet::RawSocket::read ( char *  buffer,
size_type  buffer_length 
)
overridevirtual

Reads from the socket.

Implements G::ReadWrite.

Definition at line 223 of file gsocket_unix.cpp.

◆ write()

GNet::SocketBase::ssize_type GNet::RawSocket::write ( const char *  buf,
size_type  len 
)
overridevirtual

Writes to the socket.

Implements G::ReadWrite.

Definition at line 237 of file gsocket_unix.cpp.


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