Go to the documentation of this file.
24 # define NETSOCKET_HH_
49 virtual void writeto(
const std::string& str,
50 const std::string& host,
int port);
56 std::string
read(
int timeout);
59 std::string
read(
int& port, std::string& host);
62 std::string
read(
int& port, std::string& host,
int timeout);
65 std::string
readn(
unsigned int size);
68 std::string
readn(
int timeout,
unsigned int size);
72 std::string
readn(
int& port, std::string& host,
unsigned int size);
76 std::string
readn(
int& port, std::string& host,
int timeout,
81 struct sockaddr_in
_get_addr(int port) const;
83 struct sockaddr_in6 _get_addr6(int port) const;
88 struct sockaddr_in
_get_addr(const std::string& host,
91 struct sockaddr_in6 _get_addr6(const std::string& host,
94 int
_bind(int port, const std::string& host);
113 int
_accept(int port, int server_socket) const;
115 std::string
_get_ip(int port, int socket) const;
120 const std::string& host) const;
141 unsigned int pkg_size) = 0;
145 virtual std::string
_read_line_bin(int socket, unsigned int size) = 0;
151 void
_write_str(int socket, const std::string& str,
152 const std::string& host, int port) const;
158 const std::string& host, int port) const;
std::string readn(unsigned int size)
read a string from socket
int _accept(int port, int server_socket) const
Wait for a client.
NetSocket(SOCKET_KIND kind, SOCKET_VERSION version=V4)
std::string read()
function used by >> operator (read a string on current socket)
Network namespace represent all networks connection.
This class represent an abstract socket connection (udp | tcp server | tcp client)
virtual void writeto(const std::string &str, const std::string &host, int port)
function used to send a msg to a specific host (UDP)
enum Network::e_pkind PROTO_KIND
enum Network::e_version SOCKET_VERSION
void _connect(int socket, int port, const std::string &host) const
Connect to a hostname.
void _write_str_bin(int socket, const std::string &str, const std::string &host, int port) const
Write a string to a socket to a particular host (UDP) (when used with binary protocol)
int _bind(int port, const std::string &host)
Bind a UDP server.
This class represent an abstract socket connection (udp | tcp server | tcp client)
std::string _read_line(int socket)
Get a line from socket (when used with textual protocol)
void _write_str(int socket, const std::string &str, const std::string &host, int port) const
Write a string to a socket to a particular host (UDP) (when used with textual protocol)
std::string _get_ip(int port, int socket) const
Get Client Ip.
NetSocket(SOCKET_KIND kind, PROTO_KIND pkind, SOCKET_VERSION version=V4)
struct sockaddr_in _get_addr(int port) const
internal function (construct a sockaddr)
enum Network::e_kind SOCKET_KIND
virtual std::string _read_line_bin(int socket, int &port, std::string &host, unsigned int pkg_size)=0
Get a line from socket and store client hostname and port in port and host variable (when used with b...