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
106 sockstreambuf( socket_t
socket ) throw();
116 const socket_t &
socket() const throw();
137 void close() throw();
165 void connect( const
sockaddr * dest_addr,
unsigned int timeout = 0 ) throw( sockexception, socktimeoutexception );
181 void connect( const
sockaddr * dest_addr, timeval *
timeout ) throw( sockexception, socktimeoutexception );
195 void bind( const
sockaddr * bind_addr,
bool reuse_addr = false ) throw( sockexception );
209 void listen(
int backlog = SOMAXCONN ) throw( sockexception );
223 socket_t
accept() throw( sockexception );
236 const timeval *
timeout( time_t sec, suseconds_t usec ) throw();
280 virtual
int sync() throw();
298 virtual
int overflow(
int c =
eof ) throw( socktimeoutexception );
314 virtual
int underflow() throw( socktimeoutexception );
328 bool ready( timeval *
timeout,
bool chk_read = true,
bool chk_write = true ) throw( sockexception );
343 void init_defaults() throw();
Socket exception.
Definition: sockexception.h:35
Definition: sockstreambuf.h:86
void connect(const sockaddr *dest_addr, unsigned int timeout=0)
initiate a connection on a socket
Definition: sockstreambuf.cpp:129
Definition: sockstreambuf.h:89
void listen(int backlog=SOMAXCONN)
make the socket passive and capable of accepting connections
Definition: sockstreambuf.cpp:225
Definition: sockstreambuf.h:66
socket_type_t
Definition: sockstreambuf.h:74
Definition: sockstreambuf.h:87
Definition: sockstreambuf.h:90
Definition: sockstreambuf.h:70
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:53
void cleanup_buffers()
cleanup internal buffers
Definition: sockstreambuf.cpp:304
int socket_t
Definition: sockstreambuf.h:57
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
const socket_t & socket() const
get internal socket data
Definition: sockstreambuf.cpp:247
socket_protocol_t
Definition: sockstreambuf.h:83
Definition: sockstreambuf.h:68
Definition: iosocks.cpp:23
Definition: sockstreambuf.h:61
Definition: sockstreambuf.h:67
Definition: sockstreambuf.h:84
eof_t
Definition: sockstreambuf.h:60
void close()
close open sockets
Definition: sockstreambuf.cpp:110
Socket timeout exception.
Definition: socktimeoutexception.h:36
Definition: sockstreambuf.h:69
Socket address base class.
Definition: sockaddr.h:35
bool timedout() const
get the timed-out status
Definition: sockstreambuf.cpp:282
Definition: sockstreambuf.h:85
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:65
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:88