libsocket
|
Generic class for all UNIX datagram (DGRAM) sockets, implementing i/o functions. More...
#include <unixdgram.hpp>
Public Member Functions | |
ssize_t | sndto (const void *buf, size_t length, const char *path, int sendto_flags=0) |
Send data to datagram socket. More... | |
ssize_t | sndto (const void *buf, size_t length, const string &path, int sendto_flags=0) |
Send data to datagram socket. More... | |
ssize_t | sndto (const string &buf, const string &path, int sendto_flags=0) |
Send data to datagram socket. More... | |
ssize_t | rcvfrom (void *buf, size_t length, char *source, size_t source_len, int recvfrom_flags=0) |
Receive data and store the sender's address. More... | |
ssize_t | rcvfrom (void *buf, size_t length, string &source, int recvfrom_flags=0) |
Receive data and store the sender's address. More... | |
ssize_t | rcvfrom (string &buf, string &source, int recvfrom_flags=0) |
Receive data and store the sender's address. 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 |
Generic class for all UNIX datagram (DGRAM) sockets, implementing i/o functions.
Definition at line 45 of file unixdgram.hpp.
ssize_t libsocket::unix_dgram::sndto | ( | const void * | buf, |
size_t | length, | ||
const char * | path, | ||
int | sendto_flags = 0 |
||
) |
Send data to datagram socket.
buf | Pointer to data. |
length | Length of buf |
path | Path of destination |
sendto_flags | Flags for sendto(2) |
Definition at line 59 of file unixdgram.cpp.
ssize_t libsocket::unix_dgram::sndto | ( | const void * | buf, |
size_t | length, | ||
const string & | path, | ||
int | sendto_flags = 0 |
||
) |
Send data to datagram socket.
buf | Pointer to data. |
length | Length of buf |
path | Path of destination |
sendto_flags | Flags for sendto(2) |
Definition at line 91 of file unixdgram.cpp.
ssize_t libsocket::unix_dgram::sndto | ( | const string & | buf, |
const string & | path, | ||
int | sendto_flags = 0 |
||
) |
Send data to datagram socket.
buf | Pointer to data. |
path | Path of destination |
sendto_flags | Flags for sendto(2) |
Definition at line 106 of file unixdgram.cpp.
ssize_t libsocket::unix_dgram::rcvfrom | ( | void * | buf, |
size_t | length, | ||
char * | source, | ||
size_t | source_len, | ||
int | recvfrom_flags = 0 |
||
) |
Receive data and store the sender's address.
buf | Receive buffer |
length | Length of buf |
source | Buffer for sender's path |
source_len | source 's length |
recvfrom_flags | Flags for recvfrom(2) |
Definition at line 124 of file unixdgram.cpp.
ssize_t libsocket::unix_dgram::rcvfrom | ( | void * | buf, |
size_t | length, | ||
string & | source, | ||
int | recvfrom_flags = 0 |
||
) |
Receive data and store the sender's address.
buf | Receive buffer |
length | Length of buf |
source | Buffer for sender's path. The path is truncated to source.size() characters. |
recvfrom_flags | Flags for recvfrom(2) |
Definition at line 159 of file unixdgram.cpp.
ssize_t libsocket::unix_dgram::rcvfrom | ( | string & | buf, |
string & | source, | ||
int | recvfrom_flags = 0 |
||
) |
Receive data and store the sender's address.
buf | Receive buffer. The data is truncated to buf.size() characters. |
source | Buffer for sender's path. The path is truncated to source.size() characters. |
recvfrom_flags | Flags for recvfrom(2) |
Definition at line 208 of file unixdgram.cpp.
|
inherited |
Returns the path we're bound or connected to.
Definition at line 50 of file unixbase.cpp.
|
virtualinherited |
Destroys a socket.
0 | Fine! |
<0 | Most likely the socket was already closed before. |
Definition at line 72 of file socket.cpp.
|
inherited |
Returns the socket file descriptor.
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.
|
inherited |
Set socket options on the underlying socket.
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.
|
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.
|
protectedinherited |
The path we're connected (client stream) or bound (server stream, server datagram)
Definition at line 55 of file unixbase.hpp.
|
protectedinherited |
sfd is the sockets API file descriptor
Definition at line 74 of file socket.hpp.
|
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.