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>
28 #include <netinet/in.h>
31 #ifndef SOCKSTREAMBUF_SIZE
32 #define SOCKSTREAMBUF_SIZE 1024
35 #ifndef SOCKSTREAMBUF_PUTBACK_SIZE
36 #define SOCKSTREAMBUF_PUTBACK_SIZE 8
70 sock_stream = SOCK_STREAM,
71 sock_dgram = SOCK_DGRAM,
74 sock_seqpacket = SOCK_SEQPACKET
101 sockstreambuf( socket_t
socket ) throw();
111 const socket_t &
socket() const throw();
132 void close() throw();
160 void connect( const
sockaddr * dest_addr,
unsigned int timeout = 0 ) throw( sockexception, socktimeoutexception );
176 void connect( const
sockaddr * dest_addr, timeval *
timeout ) throw( sockexception, socktimeoutexception );
190 void bind( const
sockaddr * bind_addr,
bool reuse_addr = false ) throw( sockexception );
204 void listen(
int backlog = SOMAXCONN ) throw( sockexception );
218 socket_t
accept() throw( sockexception );
231 const timeval *
timeout( time_t sec, suseconds_t usec ) throw();
275 virtual
int sync() throw();
293 virtual
int overflow(
int c =
eof ) throw( socktimeoutexception );
309 virtual
int underflow() throw( socktimeoutexception );
323 bool ready( timeval *
timeout,
bool chk_read = true,
bool chk_write = true ) throw( sockexception );
338 void init_defaults() throw();
bool timedout() const
get the timed-out status
Definition: sockstreambuf.cpp:282
Socket exception.
Definition: sockexception.h:35
Definition: sockstreambuf.h:81
void connect(const sockaddr *dest_addr, unsigned int timeout=0)
initiate a connection on a socket
Definition: sockstreambuf.cpp:129
Definition: sockstreambuf.h:84
void listen(int backlog=SOMAXCONN)
make the socket passive and capable of accepting connections
Definition: sockstreambuf.cpp:225
Definition: sockstreambuf.h:61
socket_type_t
Definition: sockstreambuf.h:69
Definition: sockstreambuf.h:82
Definition: sockstreambuf.h:85
Definition: sockstreambuf.h:65
virtual int underflow()
read more data into the buffer from the socket
Definition: sockstreambuf.cpp:391
virtual int sync()
sync data with the socket
Definition: sockstreambuf.cpp:351
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
void bind(const sockaddr *bind_addr, bool reuse_addr=false)
bind the socket to a specified address
Definition: sockstreambuf.cpp:205
virtual int flush()
flush the socket output buffer
Definition: sockstreambuf.cpp:315
Socket stream buffer class.
Definition: sockstreambuf.h:48
void cleanup_buffers()
cleanup internal buffers
Definition: sockstreambuf.cpp:304
int socket_t
Definition: sockstreambuf.h:52
virtual int overflow(int c=eof)
consumes the buffer by writing the contents to the socket
Definition: sockstreambuf.cpp:370
sockstreambuf()
constructor
Definition: sockstreambuf.cpp:33
socket_protocol_t
Definition: sockstreambuf.h:78
Definition: sockstreambuf.h:63
Definition: iosocks.cpp:23
Definition: sockstreambuf.h:56
const socket_t & socket() const
get internal socket data
Definition: sockstreambuf.cpp:247
Definition: sockstreambuf.h:62
Definition: sockstreambuf.h:79
eof_t
Definition: sockstreambuf.h:55
void close()
close open sockets
Definition: sockstreambuf.cpp:110
Socket timeout exception.
Definition: socktimeoutexception.h:36
Definition: sockstreambuf.h:64
Socket address base class.
Definition: sockaddr.h:35
Definition: sockstreambuf.h:80
const timeval * timeout(time_t sec, suseconds_t usec)
set the timeout value for the socket
Definition: sockstreambuf.cpp:252
void init_buffers()
initialise internal buffers
Definition: sockstreambuf.cpp:287
void * clear_timeout()
clear the timeout value for the socket
Definition: sockstreambuf.cpp:264
socket_domain_t
Definition: sockstreambuf.h:60
socket_t accept()
accept a connection on a listening (passive) socket
Definition: sockstreambuf.cpp:234
void open(socket_domain_t domain, socket_type_t type, socket_protocol_t proto=proto_unspec)
open a socket
Definition: sockstreambuf.cpp:89
Definition: sockstreambuf.h:83