20 #ifndef _ANCH_NETWORK_SOCKET_H_ 21 #define _ANCH_NETWORK_SOCKET_H_ 25 #include "events/observable.hpp" 26 #include "network/socketEvent.hpp" 27 #include "network/ioException.hpp" 32 typedef int socklen_t;
36 #elif defined ANCH_POSIX 38 #define INVALID_SOCKET -1 39 #define SOCKET_ERROR -1 41 typedef struct sockaddr_in SOCKADDR_IN;
42 typedef struct sockaddr SOCKADDR;
98 std::string _ipAddress;
137 Socket(
const std::string& ipAddress,
147 virtual ~
Socket() noexcept;
157 virtual
void bind() throw(
anch::network::IOException);
164 virtual
void connect() throw(
anch::network::IOException);
171 virtual
void listen() throw(
anch::network::IOException);
189 virtual
void send(const
std::
string& message) throw(
anch::network::IOException) = 0;
198 virtual
void receive(
std::
string& message) throw(
anch::network::IOException) = 0;
205 virtual
void receive() throw(
anch::network::IOException);
216 throw(
anch::network::IOException);
221 virtual
void close() noexcept;
238 virtual
int getType() const = 0;
255 _ipAddress = ipAddress;
318 #endif // _ANCH_NETWORK_SOCKET_H_ virtual void shutdown(anch::network::Direction how=anch::network::Direction::BOTH)
Definition: socket.cpp:238
virtual void receive()
Definition: socket.cpp:224
const std::string & getIpAddress() const
Definition: socket.hpp:245
void setIpAddress(uint16_t port)
Definition: socket.hpp:272
Socket(anch::network::SocketType type)
Definition: socket.cpp:62
Definition: socket.hpp:60
int getBacklog() const
Definition: socket.hpp:299
virtual void close() noexcept
Definition: socket.cpp:249
An observable implementation of the observers/observable design pattern.
Definition: observable.hpp:43
anch::network::SocketType getSocketType() const
Definition: socket.hpp:281
virtual void accept(Socket &socket)
Definition: socket.cpp:208
int _backlog
Definition: socket.hpp:111
addrinfo * _address
Definition: socket.hpp:114
uint16_t getPort() const
Definition: socket.hpp:263
SOCKET _sock
Definition: socket.hpp:108
virtual void connect()
Definition: socket.cpp:182
Definition: socket.hpp:57
AnCH framework base namespace.
Definition: base64.hpp:28
Definition: socket.hpp:85
virtual void send(const std::string &message)=0
virtual int getDomain() const =0
Definition: socket.hpp:79
virtual void listen()
Definition: socket.cpp:195
Definition: socket.hpp:63
Definition: socket.hpp:93
void setIpAddress(const std::string &ipAddress)
Definition: socket.hpp:254
virtual int getType() const =0
Definition: socket.hpp:82
virtual void bind()
Definition: socket.cpp:164
Direction
Definition: socket.hpp:77
Definition: ioException.hpp:34
void setSocketType(SocketType type)
Definition: socket.hpp:290
SocketType
Definition: socket.hpp:55
void setBacklog(int backlog)
Definition: socket.hpp:308
Definition: socket.hpp:67