libsocket
|
Provides an interface for working with UNIX STREAM sockets. More...
#include <unixclientstream.hpp>
Public Member Functions | |
unix_stream_client (void) | |
Constructor. More... | |
unix_stream_client (const char *path, int socket_flags=0) | |
Constructor, setting up a connection. More... | |
unix_stream_client (const string &path, int socket_flags=0) | |
Constructor, setting up a connection. More... | |
void | connect (const char *path, int socket_flags=0) |
Connect socket. More... | |
void | connect (const string &path, int socket_flags=0) |
Connect socket. 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) |
ssize_t | snd (const void *buf, size_t len, int flags=0) |
Send data to socket. More... | |
ssize_t | rcv (void *buf, size_t len, int flags=0) |
Receive data from socket. More... | |
void | shutdown (int method=LIBSOCKET_WRITE) |
Shut a socket down. More... | |
Protected Attributes | |
string | _path |
int | sfd |
sfd is the sockets API file descriptor More... | |
bool | is_nonblocking |
bool | close_on_destructor |
bool | shut_rd |
bool | shut_wr |
Friends | |
class | unix_stream_server |
Provides an interface for working with UNIX STREAM sockets.
Definition at line 49 of file unixclientstream.hpp.
libsocket::unix_stream_client::unix_stream_client | ( | void | ) |
Constructor.
Definition at line 55 of file unixclientstream.cpp.
libsocket::unix_stream_client::unix_stream_client | ( | const char * | path, |
int | socket_flags = 0 |
||
) |
Constructor, setting up a connection.
Constructs a UNIX stream client socket and connects it.
path | Peer (server) socket. |
socket_flags | Flags for socket(2) |
Definition at line 65 of file unixclientstream.cpp.
libsocket::unix_stream_client::unix_stream_client | ( | const string & | path, |
int | socket_flags = 0 |
||
) |
Constructor, setting up a connection.
Constructs a UNIX stream client socket and connects it.
path | Peer (server) socket. |
socket_flags | Flags for socket(2) |
Definition at line 77 of file unixclientstream.cpp.
void libsocket::unix_stream_client::connect | ( | const char * | path, |
int | socket_flags = 0 |
||
) |
Connect socket.
Connects a client stream socket.
path | The server socket's path |
socket_flags | Flags for socket(2) (Do I repeat myself?) |
Definition at line 89 of file unixclientstream.cpp.
void libsocket::unix_stream_client::connect | ( | const string & | path, |
int | socket_flags = 0 |
||
) |
Connect socket.
Connects a client stream socket.
path | The server socket's path |
socket_flags | Flags for socket(2) (Do I repeat myself?) |
Definition at line 117 of file unixclientstream.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.
|
inherited |
Send data to socket.
buf | Data to be sent |
len | Length of buf |
flags | Flags for send(2) . WARNING: Throws an exception if send() returns -1; this may be the case if the flag MSG_DONTWAIT is used. |
Definition at line 243 of file streamclient.cpp.
|
inherited |
Receive data from socket.
...and puts it in buf
.
buf | A writable memory buffer of length len |
len | Length of buf |
flags | Flags for recv(2) . WARNING: Throws an exception if recv() returns -1; this may be the case if the flag MSG_DONTWAIT is used. |
Definition at line 68 of file streamclient.cpp.
|
inherited |
Shut a socket down.
Shuts a socket down using shutdown(2)
.
method | LIBSOCKET_READ/LIBSOCKET_WRITE or an OR ed combination. |
Definition at line 279 of file streamclient.cpp.
|
friend |
unix_stream_server returns pointer to unix_stream_client objects when accepting connections.
Definition at line 58 of file unixclientstream.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.
|
protectedinherited |
If the socket was shut down for reading (-> no reads anymore)
Definition at line 54 of file streamclient.hpp.
|
protectedinherited |
If the socket was shut down for writing (-> no writes anymore)
Definition at line 56 of file streamclient.hpp.