Util--  1.1
Public Member Functions | Friends | List of all members
utilmm::socket Class Reference

#include <utilmm/system/socket.hh>

Inheritance diagram for utilmm::socket:
Inheritance graph
[legend]
Collaboration diagram for utilmm::socket:
Collaboration graph
[legend]

Public Member Functions

 socket (int fd)
 
 socket (Domain domain, Type type, std::string const &connect_to)
 
void connect (std::string const &to)
 
int read (void *buf, size_t size) const
 
int write (void const *buf, size_t size) const
 
- Public Member Functions inherited from utilmm::base_socket
 base_socket (int fd)
 
 base_socket (Domain domain, Type type)
 
 ~base_socket ()
 
int fd () const
 
bool try_wait (int what) const
 
void wait (int what) const
 
void flush () const
 

Friends

class server_socket
 

Additional Inherited Members

- Public Types inherited from utilmm::base_socket
enum  Domain { Unix, Inet }
 
enum  Type { Stream, Datagram }
 
enum  Wait { WaitRead = 1, WaitWrite = 2, WaitException = 4 }
 
- Protected Member Functions inherited from utilmm::base_socket
std::vector< uint8_t > to_sockaddr (std::string const &to) const
 

Detailed Description

A socket connected to a remote peer

Constructor & Destructor Documentation

utilmm::socket::socket ( int  fd)

Creates a socket object from an already existing file descriptor

utilmm::socket::socket ( Domain  domain,
Type  type,
std::string const &  connect_to 
)

Opens a new socket in the specified domain and of the specified type, and connect it to connect_to. connect_to is either an IP address of the form a.b.c.d:port if domain is Inet, or a Unix socket name otherwise.

Member Function Documentation

void utilmm::socket::connect ( std::string const &  to)

Connects or reconnects this socket to the specified peer. to is either an IP address of the form a.b.c.d:port if domain is Inet, or a Unix socket name otherwise.

int utilmm::socket::read ( void *  buf,
size_t  size 
) const

Reads at most size bytes in the specified buffer and returns the count of bytes actually read.

Exceptions
unix_errorraised if an error occured
int utilmm::socket::write ( void const *  buf,
size_t  size 
) const

Writes at most size bytes in the specified buffer and returns the count of bytes actually written.

Exceptions
unix_errorraised if an error occured

Friends And Related Function Documentation

friend class server_socket
friend

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

Generated on Mon Oct 8 2018 08:38:45 for Util-- by doxygen 1.8.11
SourceForge.net Project Page