20#ifndef PSOCKSXX_SOCKSTREAMBUF_H
21#define PSOCKSXX_SOCKSTREAMBUF_H
23#include <psocksxx/socktimeoutexception.h>
24#include <psocksxx/sockaddr.h>
27#include <sys/socket.h>
29#if defined(__GNU__) || defined(__gnu_hurd__)
30#include <hurd/socket.h>
33#include <netinet/in.h>
36#ifndef SOCKSTREAMBUF_SIZE
37#define SOCKSTREAMBUF_SIZE 1024
40#ifndef SOCKSTREAMBUF_PUTBACK_SIZE
41#define SOCKSTREAMBUF_PUTBACK_SIZE 8
75 sock_stream = SOCK_STREAM,
76 sock_dgram = SOCK_DGRAM,
79 sock_seqpacket = SOCK_SEQPACKET
137 void close() throw();
236 const timeval *
timeout( time_t sec, suseconds_t usec ) throw();
280 virtual
int sync() throw();
343 void init_defaults() throw();
Socket address base class.
Definition sockaddr.h:35
Socket exception.
Definition sockexception.h:35
Socket stream buffer class.
Definition sockstreambuf.h:53
const timeval * timeout(time_t sec, suseconds_t usec)
set the timeout value for the socket
Definition sockstreambuf.cpp:252
eof_t
Definition sockstreambuf.h:60
@ eof
Definition sockstreambuf.h:61
socket_protocol_t
Definition sockstreambuf.h:83
@ ipproto_ipv6
Definition sockstreambuf.h:86
@ ipproto_ip
Definition sockstreambuf.h:85
@ ipproto_icmp
Definition sockstreambuf.h:87
@ ipproto_tcp
Definition sockstreambuf.h:89
@ ipproto_udp
Definition sockstreambuf.h:90
@ ipproto_raw
Definition sockstreambuf.h:88
@ proto_unspec
Definition sockstreambuf.h:84
virtual int underflow()
read more data into the buffer from the socket
Definition sockstreambuf.cpp:391
void connect(const sockaddr *dest_addr, unsigned int timeout=0)
initiate a connection on a socket
Definition sockstreambuf.cpp:129
virtual int overflow(int c=eof)
consumes the buffer by writing the contents to the socket
Definition sockstreambuf.cpp:370
socket_domain_t
Definition sockstreambuf.h:65
@ pf_key
Definition sockstreambuf.h:69
@ pf_route
Definition sockstreambuf.h:68
@ pf_inet
Definition sockstreambuf.h:67
@ pf_local
Definition sockstreambuf.h:66
@ pf_inet6
Definition sockstreambuf.h:70
socket_t accept()
accept a connection on a listening (passive) socket
Definition sockstreambuf.cpp:234
int socket_t
Definition sockstreambuf.h:57
const socket_t & socket() const
get internal socket data
Definition sockstreambuf.cpp:247
void close()
close open sockets
Definition sockstreambuf.cpp:110
virtual int flush()
flush the socket output buffer
Definition sockstreambuf.cpp:315
socket_type_t
Definition sockstreambuf.h:74
void open(socket_domain_t domain, socket_type_t type, socket_protocol_t proto=proto_unspec)
open a socket
Definition sockstreambuf.cpp:89
sockstreambuf()
constructor
Definition sockstreambuf.cpp:33
bool ready(timeval *timeout, bool chk_read=true, bool chk_write=true)
check for the read/write availability on the socket
Definition sockstreambuf.cpp:451
virtual int sync()
sync data with the socket
Definition sockstreambuf.cpp:351
bool timedout() const
get the timed-out status
Definition sockstreambuf.cpp:282
void listen(int backlog=SOMAXCONN)
make the socket passive and capable of accepting connections
Definition sockstreambuf.cpp:225
void cleanup_buffers()
cleanup internal buffers
Definition sockstreambuf.cpp:304
void bind(const sockaddr *bind_addr, bool reuse_addr=false)
bind the socket to a specified address
Definition sockstreambuf.cpp:205
void * clear_timeout()
clear the timeout value for the socket
Definition sockstreambuf.cpp:264
void init_buffers()
initialise internal buffers
Definition sockstreambuf.cpp:287
Socket timeout exception.
Definition socktimeoutexception.h:36