Apache Mesos
|
Implementation interface for a Socket
.
More...
#include <socket.hpp>
Public Types | |
enum | Kind { Kind::POLL } |
Available kinds of implementations. More... | |
Public Member Functions | |
virtual | ~SocketImpl () |
int_fd | get () const |
Returns the file descriptor wrapped by this implementation. More... | |
Try< Address > | address () const |
Returns the Address with the assigned ip and assigned port. More... | |
Try< Address > | peer () const |
Returns the peer's Address for the accepted or connected socket. More... | |
Try< Address > | bind (const Address &address) |
Assigns the specified address to the socket. More... | |
virtual Try< Nothing > | listen (int backlog)=0 |
virtual Future< std::shared_ptr< SocketImpl > > | accept ()=0 |
Returns an implementation corresponding to the next pending connection for the listening socket. More... | |
virtual Future< Nothing > | connect (const Address &address)=0 |
virtual Future< size_t > | recv (char *data, size_t size)=0 |
virtual Future< size_t > | send (const char *data, size_t size)=0 |
virtual Future< size_t > | sendfile (int_fd fd, off_t offset, size_t size)=0 |
virtual Future< std::string > | recv (const Option< ssize_t > &size=None()) |
An overload of recv , which receives data based on the specified 'size' parameter. More... | |
virtual Future< Nothing > | send (const std::string &data) |
An overload of send , which sends all of the specified data. More... | |
virtual Try< Nothing, SocketError > | shutdown (int how) |
Shuts down the socket. More... | |
virtual Kind | kind () const =0 |
Static Public Member Functions | |
static Kind | DEFAULT_KIND () |
Returns the default Kind of implementation. More... | |
static Try< std::shared_ptr< SocketImpl > > | create (int_fd s, Kind kind=DEFAULT_KIND()) |
Returns an instance of a SocketImpl using the specified kind of implementation. More... | |
static Try< std::shared_ptr< SocketImpl > > | create (Address::Family family, Kind kind=DEFAULT_KIND()) |
Returns an instance of a SocketImpl using the specified kind of implementation. More... | |
Protected Member Functions | |
SocketImpl (int_fd _s) | |
int_fd | release () |
Releases ownership of the file descriptor. More... | |
Static Protected Member Functions | |
template<typename T > | |
static std::shared_ptr< T > | shared (T *t) |
Returns a std::shared_ptr<T> from this implementation. More... | |
Protected Attributes | |
int_fd | s |
Implementation interface for a Socket
.
Each socket is:
Multiple implementations are supported via the Pimpl pattern, rather than forcing each Socket implementation to do this themselves.
|
strong |
Available kinds of implementations.
Enumerator | |
---|---|
POLL |
|
inlinevirtual |
|
inlineexplicitprotected |
|
pure virtual |
Returns an implementation corresponding to the next pending connection for the listening socket.
All implementations will set the NONBLOCK and CLOEXEC options on the returned socket.
TODO(josephw): MESOS-5729: Consider making the CLOEXEC option configurable by the caller of the interface.
Implemented in process::network::internal::LibeventSSLSocketImpl, process::network::internal::OpenSSLSocketImpl, and process::network::internal::PollSocketImpl.
Assigns the specified address to the socket.
Address
or an error if the bind system call fails.
|
static |
Returns an instance of a SocketImpl
using the specified kind of implementation.
s. | The existing file descriptor to use. |
kind | Optional. The desired implementation. |
SocketImpl
.
|
static |
Returns an instance of a SocketImpl
using the specified kind of implementation.
The NONBLOCK and CLOEXEC options will be set on the underlying file descriptor for the socket.
kind | Optional. The desired implementation. |
SocketImpl
.
|
static |
Returns the default Kind
of implementation.
|
inline |
Returns the file descriptor wrapped by this implementation.
|
pure virtual |
|
pure virtual |
|
virtual |
An overload of recv
, which receives data based on the specified 'size' parameter.
|
inlineprotected |
Releases ownership of the file descriptor.
Not exposed via the Socket
interface as this is only intended to support Socket::Impl
implementations that need to override the file descriptor ownership.
|
pure virtual |
|
virtual |
An overload of send
, which sends all of the specified data.
data | The specified data to send. |
|
inlinestaticprotected |
Returns a std::shared_ptr<T>
from this implementation.
|
inlinevirtual |
Shuts down the socket.
Accepts an integer which specifies the shutdown mode.
Reimplemented in process::network::internal::LibeventSSLSocketImpl, and process::network::internal::OpenSSLSocketImpl.
|
protected |