Apache Mesos
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
process::network::internal::Socket< AddressType > Class Template Reference

An abstraction around a socket (file descriptor). More...

#include <socket.hpp>

Public Types

enum  Shutdown { Shutdown::READ, Shutdown::WRITE, Shutdown::READ_WRITE }
 

Public Member Functions

SocketImpl::Kind kind () const
 Returns the kind representing the underlying implementation of the Socket instance. More...
 
bool operator== (const Socket &that) const
 
 operator int_fd () const
 
Try< AddressType > address () const
 
Try< AddressType > peer () const
 
int_fd get () const
 
Try< AddressType > bind (const AddressType &address)
 
Try< Nothinglisten (int backlog)
 
Future< Socketaccept ()
 
Future< Nothingconnect (const AddressType &address)
 
Future< size_t > recv (char *data, size_t size) const
 
Future< size_t > send (const char *data, size_t size) const
 
Future< size_t > sendfile (int_fd fd, off_t offset, size_t size) const
 
Future< std::string > recv (const Option< ssize_t > &size=None())
 
Future< Nothingsend (const std::string &data)
 
Try< Nothingshutdown (Shutdown shutdown=Shutdown::READ)
 
 operator Socket< network::Address > () const
 
template<>
Try< Socket< network::Address > > create (SocketImpl::Kind kind)=delete
 
template<>
Try< Socket< network::Address > > create (Address::Family family, SocketImpl::Kind kind)
 
template<>
Try< Socket< inet::Address > > create (SocketImpl::Kind kind)
 
template<>
Try< Socket< inet::Address > > create (Address::Family family, SocketImpl::Kind kind)=delete
 
template<>
Try< Socket< unix::Address > > create (SocketImpl::Kind kind)
 
template<>
Try< Socket< unix::Address > > create (Address::Family family, SocketImpl::Kind kind)=delete
 

Static Public Member Functions

static Try< Socketcreate (int_fd s, SocketImpl::Kind kind=SocketImpl::DEFAULT_KIND())
 Returns an instance of a Socket using the specified kind of implementation. More...
 
static Try< Socketcreate (SocketImpl::Kind kind=SocketImpl::DEFAULT_KIND())
 Returns an instance of a Socket using AddressType to determine the address family to use. More...
 
static Try< Socketcreate (Address::Family family, SocketImpl::Kind kind=SocketImpl::DEFAULT_KIND())
 Returns an instance of a Socket using the specified Address::Family to determine the address family to use. More...
 

Friends

template<typename T >
class Socket
 

Detailed Description

template<typename AddressType>
class process::network::internal::Socket< AddressType >

An abstraction around a socket (file descriptor).

Provides reference counting such that the socket is only closed (and thus, has the possibility of being reused) after there are no more references.

Member Enumeration Documentation

template<typename AddressType>
enum process::network::internal::Socket::Shutdown
strong
Enumerator
READ 
WRITE 
READ_WRITE 

Member Function Documentation

template<typename AddressType>
Future<Socket> process::network::internal::Socket< AddressType >::accept ( )
inline
template<typename AddressType>
Try<AddressType> process::network::internal::Socket< AddressType >::address ( ) const
inline
template<typename AddressType>
Try<AddressType> process::network::internal::Socket< AddressType >::bind ( const AddressType &  address)
inline
template<typename AddressType>
Future<Nothing> process::network::internal::Socket< AddressType >::connect ( const AddressType &  address)
inline
template<typename AddressType>
static Try<Socket> process::network::internal::Socket< AddressType >::create ( int_fd  s,
SocketImpl::Kind  kind = SocketImpl::DEFAULT_KIND() 
)
inlinestatic

Returns an instance of a Socket using the specified kind of implementation.

Parameters
sOptional. The file descriptor to wrap with the Socket.
kindOptional. The desired Socket implementation.
Returns
An instance of a Socket.
template<typename AddressType>
static Try<Socket> process::network::internal::Socket< AddressType >::create ( SocketImpl::Kind  kind = SocketImpl::DEFAULT_KIND())
static

Returns an instance of a Socket using AddressType to determine the address family to use.

An optional implementation kind can be specified. The NONBLOCK and CLOEXEC options will be set on the underlying file descriptor for the socket.

Parameters
kindOptional. The desired Socket implementation.
Returns
An instance of a Socket.
template<typename AddressType>
static Try<Socket> process::network::internal::Socket< AddressType >::create ( Address::Family  family,
SocketImpl::Kind  kind = SocketImpl::DEFAULT_KIND() 
)
static

Returns an instance of a Socket using the specified Address::Family to determine the address family to use.

An optional implementation kind can be specified. The NONBLOCK and CLOEXEC options will be set on the underlying file descriptor for the socket.

NOTE: this is only defined for AddressType of network::Address, all others are explicitly deleted.

Parameters
kindOptional. The desired Socket implementation.
Returns
An instance of a Socket.
template<typename AddressType>
int_fd process::network::internal::Socket< AddressType >::get ( ) const
inline
template<typename AddressType>
SocketImpl::Kind process::network::internal::Socket< AddressType >::kind ( ) const
inline

Returns the kind representing the underlying implementation of the Socket instance.

See Also
process::network::Socket::Kind
template<typename AddressType>
Try<Nothing> process::network::internal::Socket< AddressType >::listen ( int  backlog)
inline
template<typename AddressType>
process::network::internal::Socket< AddressType >::operator int_fd ( ) const
inline
template<typename AddressType>
process::network::internal::Socket< AddressType >::operator Socket< network::Address > ( ) const
inline
template<typename AddressType>
bool process::network::internal::Socket< AddressType >::operator== ( const Socket< AddressType > &  that) const
inline
template<typename AddressType>
Try<AddressType> process::network::internal::Socket< AddressType >::peer ( ) const
inline
template<typename AddressType>
Future<size_t> process::network::internal::Socket< AddressType >::recv ( char *  data,
size_t  size 
) const
inline
template<typename AddressType>
Future<std::string> process::network::internal::Socket< AddressType >::recv ( const Option< ssize_t > &  size = None())
inline
template<typename AddressType>
Future<size_t> process::network::internal::Socket< AddressType >::send ( const char *  data,
size_t  size 
) const
inline
template<typename AddressType>
Future<Nothing> process::network::internal::Socket< AddressType >::send ( const std::string &  data)
inline
template<typename AddressType>
Future<size_t> process::network::internal::Socket< AddressType >::sendfile ( int_fd  fd,
off_t  offset,
size_t  size 
) const
inline
template<typename AddressType>
Try<Nothing> process::network::internal::Socket< AddressType >::shutdown ( Shutdown  shutdown = Shutdown::READ)
inline

Friends And Related Function Documentation

template<typename AddressType>
template<typename T >
friend class Socket
friend

The documentation for this class was generated from the following file: