CarobNS::BufferedSocket Class Reference

Extends the JavaSocket class to allow buffered read operations. More...

#include <BufferedSocket.hpp>

Inheritance diagram for CarobNS::BufferedSocket:

CarobNS::JavaSocket CarobNS::DriverSocket List of all members.

Public Member Functions

void flush () const throw (SocketIOException, UnexpectedException)
 Sends the buffered write data to the socket.

Protected Member Functions

 BufferedSocket () throw (CodecException)
 Empty constructor.
int32_t recvFully (void *buf, const int len, const int flags) const throw (SocketIOException, UnexpectedException)
 Substitute for recv.
void sendToSocket (const wchar_t fctName[], const void *buf, int len, int flags) const throw (SocketIOException, UnexpectedException)
 Wrapper over send(.

Detailed Description

Extends the JavaSocket class to allow buffered read operations.

See also:
JavaSocket


Member Function Documentation

int32_t CarobNS::BufferedSocket::recvFully ( void *  buf,
const int  len,
const int  flags 
) const throw (SocketIOException, UnexpectedException) [protected, virtual]

Substitute for recv.

Waits for incomming data by calling pollOnSingleFd and loops until full length has been received or an error occured. If shutdown() is called during the loop, throws a SocketIOException to inform callers that the socket is not longer readable. If there are output data to be sent in the write buffer, this function will flush these data. This prevents from doing a flush() everywhere in the code, but still can be overriden by calling manually flush() (could be an optimization (?))

Parameters:
buf data to send
len full buffer length
flags send options, see recv man page
Returns:
the total number of bytes send, -1 in case of failure
Exceptions:
SocketIOException if interrupted by shutdown() function

Reimplemented from CarobNS::JavaSocket.

void CarobNS::BufferedSocket::sendToSocket ( const wchar_t  fctName[],
const void *  buf,
int  len,
int  flags 
) const throw (SocketIOException, UnexpectedException) [protected, virtual]

Wrapper over send(.

..) function to buffer output data and handle errors.
Data is only sent to the socket when the buffer is full or when a read operation is requested.

Parameters:
fctName name of the calling function (for logging purposes)
buf data to be send
len length of buf
flags send option, see recv man page
Exceptions:
SocketIOException 
See also:
recvFully(void *, const int, const int) const

Reimplemented from CarobNS::JavaSocket.


The documentation for this class was generated from the following file:
Generated on Fri Mar 9 17:40:20 2007 for Carob by  doxygen 1.4.7