ui-utilcpp 1.10.3
|
#include <Socket.hpp>
Public Member Functions | |
UnixSocket (std::string const &path, bool closeFd=true) | |
UnixSocket (int fd, bool closeFd=false) | |
UnixSocket & | unixBind (uid_t uid=::geteuid(), gid_t gid=::getegid(), mode_t mode=S_IRUSR|S_IWUSR, bool silentUnlink=true) |
Bind this unix socket. | |
virtual UnixSocket & | bind () |
Bind this socket. | |
virtual UnixSocket & | connect () |
Connect this socket. | |
![]() | |
Socket (int fd=-1, bool closeFd=false) | |
Construct socket. | |
std::string | getId (bool const &peer=false) const |
Get human-readable id string. | |
std::string | getPeerId () const |
Get peer id. | |
Socket & | listen (int backlog=16) |
Start listening. | |
int | accept (long int toSeconds=0, long int toMicroSeconds=0) |
Accept an incoming socket connection. | |
int | shutdown (int how, bool doThrow=true) |
Shutdown socket. | |
virtual std::streamsize | read (void *const buf, std::streamsize count) |
C++-like virtual read method. | |
virtual std::streamsize | write (void const *const buf, std::streamsize count) |
C++-like virtual write method. | |
Socket & | setRcvTimeout (long int seconds, long int microseconds=0) |
Socket & | setSndTimeout (long int seconds, long int microseconds=0) |
Socket & | setUnblock (bool unblock=true) |
ssize_t | recv (void *const buf, size_t len, int flags=0) |
ssize_t | send (void const *const msg, size_t len, int flags=0) |
![]() | |
FileDescriptor (int fd=-1, bool closeFd=false) | |
Constructor from file descriptor. | |
virtual | ~FileDescriptor () |
Destructor. | |
int | getFd () const |
Get file descriptor. | |
Additional Inherited Members | |
![]() | |
enum | ErrorCode { OpenErr_ = 1 , ReadErr_ , WriteErr_ , LockErr_ , UnlockErr_ , BindErr_ , ConnectErr_ , UnblockErr_ , ListenErr_ , ShutdownErr_ } |
Error codes for exceptions. | |
typedef CodeException< ErrorCode > | Exception |
Exceptions for this class. | |
![]() | |
static void | fdClose (int const &fd, std::string const &id, bool const &doClose=true) |
Helper to close file descriptors from destructors. | |
![]() | |
void | init (int fd, bool closeFd=false) |
To be called in a constructor. | |
![]() | |
int | fd_ |
The file descriptor that is managed. | |
Unix Socket.
|
virtual |
|
virtual |
Connect this socket.
Reimplemented from UI::Util::Socket.
References UI::Util::FileDescriptor::fd_, UI::Util::Socket::getId(), and UI_THROW_CODE.
UnixSocket & UI::Util::UnixSocket::unixBind | ( | uid_t | uid = ::geteuid() , |
gid_t | gid = ::getegid() , |
||
mode_t | mode = S_IRUSR | S_IWUSR , |
||
bool | silentUnlink = true |
||
) |
Bind this unix socket.
References UI::Util::FileDescriptor::fd_, UI::Util::Socket::getId(), and UI_THROW_CODE.
Referenced by bind().