![]() |
AnCH Framework
0.1
Another C++ Hack Framework
|
#include <socket.hpp>
Public Member Functions | |
Socket (const std::string &ipAddress, uint16_t port, anch::network::SocketType type=anch::network::SocketType::UNKNOWN) throw (anch::network::IOException) | |
virtual | ~Socket () noexcept |
virtual void | bind () throw (anch::network::IOException) |
virtual void | connect () throw (anch::network::IOException) |
virtual void | listen () throw (anch::network::IOException) |
virtual void | accept (Socket &socket) throw (anch::network::IOException) |
virtual void | send (const std::string &message)=0 throw (anch::network::IOException) |
virtual void | receive (std::string &message)=0 throw (anch::network::IOException) |
virtual void | receive () throw (anch::network::IOException) |
virtual void | shutdown (anch::network::Direction how=anch::network::Direction::BOTH) throw (anch::network::IOException) |
virtual void | close () noexcept |
virtual int | getDomain () const =0 |
virtual int | getType () const =0 |
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) |
![]() | |
Observable () | |
virtual | ~Observable () |
bool | addObserver (anch::events::Observer< anch::network::SocketEvent > &observer) |
void | removeObserver (anch::events::Observer< anch::network::SocketEvent > &observer) |
void | notifyObservers (const anch::network::SocketEvent &event) |
Protected Member Functions | |
Socket (anch::network::SocketType type) | |
Protected Attributes | |
SOCKET | _sock |
int | _backlog |
addrinfo * | _address |
Network socket management class
|
protected |
Socket constructor.
type | The socket type |
Socket::Socket | ( | const std::string & | ipAddress, |
uint16_t | port, | ||
anch::network::SocketType | type = anch::network::SocketType::UNKNOWN |
||
) | |||
throw | ( | anch::network::IOException | |
) |
Socket constructor.
Backlog is set to 5 by default. You can change it using the setter before call listen method.
ipAddress | IP address |
port | Destination port |
type | The socket type |
anch::network::IOException | Error while creating the socket |
|
virtualnoexcept |
Socket destructor
|
virtual |
Accept client connection
socket | The socket which describes client connection |
anch::network::IOException | Error while accepting client connection |
Accept client connection
anch::network::IOException | Error while accepting client connection |
Reimplemented in anch::network::UdpSocket.
|
virtual |
Bind socket
anch::network::IOException | Error while binding the socket |
|
virtualnoexcept |
Close the socket
|
virtual |
Connect to remote socket
anch::network::IOException | Error while connectin the client socket to the server socket |
Reimplemented in anch::network::UdpSocket.
|
inline |
Backlog getter
|
pure virtual |
Get the socket domain
Implemented in anch::network::UdpSocket, and anch::network::TcpSocket.
|
inline |
IP address getter
|
inline |
Destination port getter
|
inline |
Socket type getter
|
pure virtual |
Get the socket service type
Implemented in anch::network::UdpSocket, and anch::network::TcpSocket.
|
virtual |
Listen on socket
anch::network::IOException | Error while listening on the socket |
Reimplemented in anch::network::UdpSocket.
|
pure virtual |
Receive a message on socket
message | The messages which has been received |
anch::network::IOException | Network error while receiving message |
Implemented in anch::network::UdpSocket, and anch::network::TcpSocket.
|
virtual |
Receive a message on socket
anch::network::IOException | Network error while receiving message |
|
pure virtual |
Send a message on socket
message | The message to send |
anch::network::IOException | Network error while sending message |
Implemented in anch::network::UdpSocket, and anch::network::TcpSocket.
|
inline |
Backlog setter
backlog | The backlog to set |
|
inline |
IP address setter
ipAddress | The IP address to set |
|
inline |
Destination port setter
port | The destination port to set |
|
inline |
Socket type setter
type | The socket type to set |
|
virtual |
Shutdown data flow between client and server.
This method has to be called by server.
how | Direction of the data flow which has to be closed |
anch::network::IOException | Network error while shutting down data transfer |
Shutdown data flow between client and server.
This method has to be called by server.
how | Direction of the data flow which has to be closed |
anch::network::IOException | Network error while shutting down data transfer |
|
protected |
The address informations
|
protected |
The number of connection in waiting state
|
protected |
The socket