Fawkes API
Fawkes Development Version
|
TCP stream socket over IP. More...
#include <netcomm/socket/stream.h>
Public Member Functions | |
StreamSocket (float timeout=0.f) | |
Constructor. | |
StreamSocket (StreamSocket &s) | |
Copy constructor. | |
virtual Socket * | clone () |
Clone socket. | |
void | set_nodelay (bool no_delay) |
Enable or disable Nagle algorithm. | |
bool | nodelay () |
Check if Nalge algorithm is disabled. | |
![]() | |
Socket (int domain, int type, int protocol, float timeout=0.f) | |
Constructor similar to syscall. | |
Socket (Socket &socket) | |
Copy constructor. | |
virtual | ~Socket () |
Destructor. | |
virtual void | connect (const char *hostname, const unsigned short int port) |
Connect socket. | |
virtual void | connect (struct sockaddr *addr_port, unsigned int struct_size) |
Connect socket. | |
virtual void | bind (const unsigned short int port) |
Bind socket. | |
virtual void | bind (const unsigned short int port, const char *hostname) |
Bind socket to a specific address. | |
virtual void | listen (int backlog=1) |
Listen on socket. | |
virtual Socket * | accept () |
Accept connection. | |
virtual void | close () |
Close socket. | |
virtual bool | available () |
Check if data is available. | |
virtual size_t | read (void *buf, size_t count, bool read_all=true) |
Read from socket. | |
virtual void | write (const void *buf, size_t count) |
Write to the socket. | |
virtual void | send (void *buf, size_t buf_len) |
Write to the socket. | |
virtual void | send (void *buf, size_t buf_len, const struct sockaddr *to_addr, socklen_t addr_len) |
Send message. | |
virtual size_t | recv (void *buf, size_t buf_len) |
Read from socket. | |
virtual size_t | recv (void *buf, size_t buf_len, struct sockaddr *from_addr, socklen_t *addr_len) |
Receive data. | |
virtual short | poll (int timeout=-1, short what=POLL_IN|POLL_HUP|POLL_PRI|POLL_RDHUP) |
Wait for some event on socket. | |
virtual bool | listening () |
Is socket listening for connections? | |
virtual unsigned int | mtu () |
Maximum Transfer Unit (MTU) of socket. | |
template<class SocketType > | |
SocketType * | accept () |
Accept connection. |
Additional Inherited Members | |
![]() | |
static const short | POLL_IN = POLLIN |
Data can be read. | |
static const short | POLL_OUT = POLLOUT |
Writing will not block. | |
static const short | POLL_PRI = POLLPRI |
There is urgent data to read (e.g., out-of-band data on TCP socket; pseudo-terminal master in packet mode has seen state change in slave). | |
static const short | POLL_RDHUP = 0 |
Stream socket peer closed connection, or shut down writing half of connection. | |
static const short | POLL_ERR = POLLERR |
Error condition. | |
static const short | POLL_HUP = POLLHUP |
Hang up. | |
static const short | POLL_NVAL = POLLNVAL |
Invalid request. | |
![]() | |
Socket () | |
Constructor. | |
![]() | |
int | sock_fd |
Socket file descriptor. | |
float | timeout |
Timeout in seconds for various operations. | |
struct::sockaddr_in * | client_addr |
Client address, set if connected. | |
unsigned int | client_addr_len |
length in bytes of client address. |
fawkes::StreamSocket::StreamSocket | ( | float | timeout = 0.f | ) |
Constructor.
timeout | timeout, if 0 all operationsare blocking, otherwise it is tried for timeout seconds. |
Definition at line 46 of file stream.cpp.
Referenced by clone().
fawkes::StreamSocket::StreamSocket | ( | StreamSocket & | stream_socket | ) |
|
virtual |
Clone socket.
Implements fawkes::Socket.
Definition at line 65 of file stream.cpp.
References StreamSocket().
bool fawkes::StreamSocket::nodelay | ( | ) |
Check if Nalge algorithm is disabled.
This checks the TCP_NODELAY option on the socket. If it is set then the Nagle algorithm is disabled and all data is send out immediately.
Definition at line 78 of file stream.cpp.
References fawkes::Socket::sock_fd.
void fawkes::StreamSocket::set_nodelay | ( | bool | nodelay | ) |
Enable or disable Nagle algorithm.
nodelay | true to disable Nagle algorithm, false to enable it |
Definition at line 94 of file stream.cpp.
References fawkes::Socket::sock_fd.