dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
25 #include <sys/socket.h>
26 #include <sys/types.h>
37 int flags = MSG_NOSIGNAL;
38 if ( more ) flags = flags | MSG_MORE;
41 const char* cp = (
const char*)buf;
63 const char* cp = (
const char*)buf;
65 rc = ::sendto(
socket_, cp, left, flags, (
const sockaddr*)&(address.
addr_),
sizeof(address.
addr_) );
83 ssize_t rc = ::recv(
socket_, buf, request, 0 );
103 if ( errno != EAGAIN && errno != EWOULDBLOCK )
Socket()
Default constructor creates an invalid socket.
@ ecENOTCONN
107 Transport endpoint is not connected
@ ecECONNREFUSED
111 Connection refused
Generic network Address, supporting ipv4 and ipv6 transparently.
virtual common::SystemError receive(void *buf, ssize_t request, ssize_t &received)
Receive bytes.
static Socket SocketInvalid
An invalid SocketInvalid for comparison convenience - initialized to a Socket with socket fd=-1.
virtual common::SystemError sendTo(const Address &address, const void *buf, ssize_t len)
Send raw packets to the given Address.
int socket_
The socket file decsriptor.
#define throw_SystemExceptionObject(what, errno, thing)
Throws an Exception with errno, passes FILE and LINE to constructor.
@ ecOK
0 Not an error, success
Interface for network communication.
virtual Socket * accept()
Accepts a connection request and return a pointer to a new Socket for the new connection,...
Linux system error primitive to provide a consistent interface to Linux error codes.
struct sockaddr_storage addr_
The address storage (for either ipv4 or ipv6).
@ ecECONNRESET
104 Connection reset by peer
virtual common::SystemError send(const void *buf, ssize_t len, bool more=false)
Send len bytes as a bytestream.