JavaSocket
class to allow buffered read operations.
More...
#include <BufferedSocket.hpp>
Inheritance diagram for CarobNS::BufferedSocket:
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(. |
JavaSocket
class to allow buffered read operations.
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 (?))
buf | data to send | |
len | full buffer length | |
flags | send options, see recv man page |
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.
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 |
SocketIOException |
Reimplemented from CarobNS::JavaSocket.