8 #ifndef _TASKS_SOCKET_H_
9 #define _TASKS_SOCKET_H_
15 #include <sys/types.h>
16 #include <sys/socket.h>
22 #define SEND_RECV_FLAGS MSG_NOSIGNAL
24 #define SEND_RECV_FLAGS 0
58 inline std::shared_ptr<struct sockaddr_in>
addr() {
return m_addr; }
69 void bind(
int port, std::string ip =
"");
75 void listen(std::string path,
int queue_size = 128);
82 void listen(
int port, std::string ip =
"",
int queue_size = 128);
96 void connect(std::string host,
int port);
107 std::streamsize
write(
const char* data, std::size_t len,
int port = -1, std::string ip =
"");
113 std::streamsize
read(
char* data, std::size_t len);
118 std::shared_ptr<struct sockaddr_in>
m_addr;
120 void bind(
int port, std::string ip,
bool udp);
127 #endif // _TASKS_SOCKET_H_
void bind(int port, std::string ip="")
std::streamsize write(const char *data, std::size_t len, int port=-1, std::string ip="")
std::shared_ptr< struct sockaddr_in > addr()
std::streamsize read(char *data, std::size_t len)
Base class for socket and term.
socket accept()
Accept new client connections.
void shutdown()
Call shutdown on the fd.
void init_sockaddr(int port, std::string ip="")
void set_blocking()
Set the socket to blocking mode.
void connect(std::string path)
void listen(std::string path, int queue_size=128)
std::shared_ptr< struct sockaddr_in > m_addr