libsocket
Public Member Functions | Protected Attributes | List of all members
libsocket::unix_stream_server Class Reference

Socket class for UNIX-domain STREAM socket server. More...

#include <unixserverstream.hpp>

Inheritance diagram for libsocket::unix_stream_server:
Inheritance graph
[legend]

Public Member Functions

 unix_stream_server (void)
 Void constructor. More...
 
 unix_stream_server (const char *path, int flags=0)
 Constructs and binds server socket. More...
 
 unix_stream_server (const string &path, int flags=0)
 Constructs and binds server socket. More...
 
void setup (const char *path, int flags=0)
 Sets a server socket up. More...
 
void setup (const string &path, int flags=0)
 Sets a server socket up. More...
 
unix_stream_clientaccept (int flags=0)
 Accepts incoming connections on a UNIX domain stream server socket. More...
 
unique_ptr< unix_stream_clientaccept2 (int flags=0)
 Accepts an incoming connection on a UNIX domain stream server socket and returns an owned pointer. More...
 
string get_path (void)
 Returns the path we're bound or connected to. More...
 
virtual int destroy (void)
 Destroys a socket. More...
 
int getfd (void) const
 Returns the socket file descriptor. More...
 
int set_sock_opt (int level, int optname, const char *optval, socklen_t optlen) const
 Set socket options on the underlying socket. More...
 
void set_close_on_destructor (bool cod)
 

Protected Attributes

string _path
 
int sfd
 sfd is the sockets API file descriptor More...
 
bool is_nonblocking
 
bool close_on_destructor
 

Detailed Description

Socket class for UNIX-domain STREAM socket server.

Definition at line 51 of file unixserverstream.hpp.

Constructor & Destructor Documentation

◆ unix_stream_server() [1/3]

libsocket::unix_stream_server::unix_stream_server ( void  )

Void constructor.

Definition at line 49 of file unixserverstream.cpp.

◆ unix_stream_server() [2/3]

libsocket::unix_stream_server::unix_stream_server ( const char *  path,
int  flags = 0 
)

Constructs and binds server socket.

Parameters
pathBind path.
flagsFlags for socket(2)

Definition at line 57 of file unixserverstream.cpp.

Here is the call graph for this function:

◆ unix_stream_server() [3/3]

libsocket::unix_stream_server::unix_stream_server ( const string &  path,
int  flags = 0 
)

Constructs and binds server socket.

Parameters
pathBind path.
flagsFlags for socket(2)

Definition at line 67 of file unixserverstream.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ setup() [1/2]

void libsocket::unix_stream_server::setup ( const char *  path,
int  flags = 0 
)

Sets a server socket up.

Parameters
pathBind path.
flagsFlags for socket(2)

Definition at line 77 of file unixserverstream.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup() [2/2]

void libsocket::unix_stream_server::setup ( const string &  path,
int  flags = 0 
)

Sets a server socket up.

Parameters
pathBind path.
flagsFlags for socket(2)

Definition at line 103 of file unixserverstream.cpp.

Here is the call graph for this function:

◆ accept()

unix_stream_client * libsocket::unix_stream_server::accept ( int  flags = 0)

Accepts incoming connections on a UNIX domain stream server socket.

Parameters
flagsFlags for Linux' accept4(); useless on other implementations.

Definition at line 112 of file unixserverstream.cpp.

Here is the call graph for this function:

◆ accept2()

unique_ptr< unix_stream_client > libsocket::unix_stream_server::accept2 ( int  flags = 0)

Accepts an incoming connection on a UNIX domain stream server socket and returns an owned pointer.

The owned pointer will be closed on destruction.

Parameters
flagsFlags for accept4(); useless on other implementations.

Definition at line 124 of file unixserverstream.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_path()

string libsocket::unix_socket::get_path ( void  )
inherited

Returns the path we're bound or connected to.

Definition at line 50 of file unixbase.cpp.

◆ destroy()

int libsocket::socket::destroy ( void  )
virtualinherited

Destroys a socket.

Return values
0Fine!
<0Most likely the socket was already closed before.

Definition at line 72 of file socket.cpp.

Here is the caller graph for this function:

◆ getfd()

int libsocket::socket::getfd ( void  ) const
inherited

Returns the socket file descriptor.

Returns
The socket file descriptor of the class.

getfd() is a getter you may use to obtain the file descriptor for raw operations on it. It's relatively uncritical as libsocket just wraps other syscalls and doesn't manipulate it using unusual ways.

Definition at line 91 of file socket.cpp.

◆ set_sock_opt()

int libsocket::socket::set_sock_opt ( int  level,
int  optname,
const char *  optval,
socklen_t  optlen 
) const
inherited

Set socket options on the underlying socket.

Returns
The return value of setsockopt(2).

Sets socket options using setsockopt(2). See setsockopt(2), tcp(7), udp(7), unix(7) for documentation on how to use this function.

Definition at line 101 of file socket.cpp.

◆ set_close_on_destructor()

void libsocket::socket::set_close_on_destructor ( bool  cod)
inlineinherited

close_on_destructor is true by default. If set to false, do not call close(2) on the underlying socket in the destructor.

Definition at line 95 of file socket.hpp.

Member Data Documentation

◆ _path

string libsocket::unix_socket::_path
protectedinherited

The path we're connected (client stream) or bound (server stream, server datagram)

Definition at line 55 of file unixbase.hpp.

◆ sfd

int libsocket::socket::sfd
protectedinherited

sfd is the sockets API file descriptor

Definition at line 74 of file socket.hpp.

◆ close_on_destructor

bool libsocket::socket::close_on_destructor
protectedinherited

Default is true; if set to false, the file descriptor is not closed when the destructor is called.

Definition at line 78 of file socket.hpp.


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