AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::network::UdpSocket Class Reference

#include <udpSocket.hpp>

+ Inheritance diagram for anch::network::UdpSocket:
+ Collaboration diagram for anch::network::UdpSocket:

Public Member Functions

 UdpSocket ()
 
 UdpSocket (const std::string &ipAddress, uint16_t port)
 
virtual ~UdpSocket () noexcept
 
virtual void listen ()
 
virtual void connect ()
 
virtual void accept (Socket &socket)
 
virtual void send (const std::string &message)
 
virtual void send (const std::string &message, const sockaddr_storage &peerAddr)
 
virtual void receive (std::string &message)
 
virtual int getDomain () const
 
virtual int getType () const
 
- Public Member Functions inherited from anch::network::Socket
 Socket (const std::string &ipAddress, uint16_t port, SocketType type=SocketType::UNKNOWN)
 
virtual ~Socket () noexcept
 
virtual void bind ()
 
virtual void receive ()
 
virtual void shutdown (Direction how=Direction::BOTH)
 
virtual void close () noexcept
 
const std::string & getIpAddress () const
 
void setIpAddress (const std::string &ipAddress)
 
uint16_t getPort () const
 
void setIpAddress (uint16_t port)
 
anch::network::SocketType getSocketType () const
 
void setSocketType (SocketType type)
 
int getBacklog () const
 
void setBacklog (int backlog)
 
- Public Member Functions inherited from anch::events::Observable< SocketEvent >
 Observable ()
 
virtual ~Observable ()
 
bool addObserver (anch::events::Observer< SocketEvent > &observer)
 
void removeObserver (anch::events::Observer< SocketEvent > &observer)
 
void notifyObservers (const SocketEvent &event, const std::map< std::string, std::string > &headers={})
 
void notifyObservers (const anch::events::Event< SocketEvent > &event)
 

Additional Inherited Members

- Protected Member Functions inherited from anch::network::Socket
 Socket (SocketType type)
 
- Protected Attributes inherited from anch::network::Socket
SOCKET _sock
 
int _backlog
 
addrinfo * _address
 

Detailed Description

UDP socket implementation

Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ UdpSocket() [1/2]

anch::network::UdpSocket::UdpSocket ( )

UdpSocket default constructor

◆ UdpSocket() [2/2]

anch::network::UdpSocket::UdpSocket ( const std::string & ipAddress,
uint16_t port )

UdpSocket constructor

Parameters
ipAddressThe IP address
portThe port number
Exceptions
anch::network::IOExceptionError while creating the socket

◆ ~UdpSocket()

virtual anch::network::UdpSocket::~UdpSocket ( )
virtualnoexcept

UdpSocket destructor

Member Function Documentation

◆ accept()

virtual void anch::network::UdpSocket::accept ( Socket & socket)
virtual

Accept client connection.
This method do nothing since UDP is not connected

Parameters
socketThe socket which describes client connection
Exceptions
anch::network::IOExceptionNever on UDP socket

Reimplemented from anch::network::Socket.

+ Here is the call graph for this function:

◆ connect()

virtual void anch::network::UdpSocket::connect ( )
virtual

Connect to remote socket.
This method do nothing since UDP is not connected.

Exceptions
anch::network::IOExceptionNever on UDP socket

Reimplemented from anch::network::Socket.

+ Here is the call graph for this function:

◆ getDomain()

virtual int anch::network::UdpSocket::getDomain ( ) const
virtual

Get the socket domain

Returns
The POSIX socket domain

Implements anch::network::Socket.

+ Here is the call graph for this function:

◆ getType()

virtual int anch::network::UdpSocket::getType ( ) const
virtual

Get the socket service type

Returns
The POSIX socket service type

Implements anch::network::Socket.

+ Here is the call graph for this function:

◆ listen()

virtual void anch::network::UdpSocket::listen ( )
virtual

Listen on socket

Exceptions
anch::network::IOExceptionError while listening on the socket

Reimplemented from anch::network::Socket.

+ Here is the call graph for this function:

◆ receive()

virtual void anch::network::UdpSocket::receive ( std::string & message)
virtual

Receive a message on socket

Parameters
messageThe string where to write the message
Exceptions
anch::network::IOExceptionNetwork error while receiving message

Implements anch::network::Socket.

+ Here is the call graph for this function:

◆ send() [1/2]

virtual void anch::network::UdpSocket::send ( const std::string & message)
virtual

Send a message on socket

Parameters
messageThe message to send
Exceptions
anch::network::IOExceptionNetwork error while sending message

Implements anch::network::Socket.

+ Here is the call graph for this function:

◆ send() [2/2]

virtual void anch::network::UdpSocket::send ( const std::string & message,
const sockaddr_storage & peerAddr )
virtual

Send a message on socket

Parameters
messageThe message to send
peerAddrThe address where the message has to be sent
Exceptions
anch::network::IOExceptionNetwork error while sending message
+ Here is the call graph for this function:

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