#include <vpr/IO/Socket/Socket_t.h>
Inheritance diagram for vpr::Socket_t< SockConfig_ >:


Public Types | |
| typedef SockConfig_ | Config |
| typedef Config::SocketImpl | SocketImpl |
| typedef Config::SocketIOStatsStrategy | DefaultIOStatsStrategy |
Public Member Functions | |
| virtual const std::string & | getName () const |
| Gets the "name" of this socket. | |
| vpr::ReturnStatus | open () |
| Opens the socket. | |
| vpr::ReturnStatus | close () |
| Closes the socket. | |
| bool | isOpen () const |
| Gets the open state of this socket. | |
| bool | isBound () const |
| Gets the bound state of this socket. | |
| bool | isConnected () const |
| Gets the status of a possibly connected socket. | |
| vpr::IOSys::Handle | getHandle () const |
| Gets the handle to this socket. | |
| bool | isBlockingFixed () const |
| Queries if the blocking state for this socket is fixed and can no longer be changed. | |
| vpr::ReturnStatus | setBlocking (bool blocking) |
| Reconfigures the socket so that it is in blocking or non-blocking mode depending on the value of the parameter. | |
| bool | isBlocking () const |
| Gets the current blocking state for the socket. | |
| vpr::ReturnStatus | bind () |
| Binds this socket to the address in the host address member variable. | |
| vpr::ReturnStatus | connect (const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Connects the socket on the client side to the server side. | |
| vpr::ReturnStatus | recv (void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives at most the specified number of bytes from the socket into the given buffer. | |
| vpr::ReturnStatus | recv (std::string &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives at most the specified number of bytes from the socket into the given buffer. | |
| vpr::ReturnStatus | recv (std::vector< vpr::Uint8 > &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives at most the specified number of bytes from the socket into the given buffer. | |
| vpr::ReturnStatus | recvn (void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives exactly the specified number of bytes from the socket into the given buffer. | |
| vpr::ReturnStatus | recvn (std::string &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives exactly the specified number of bytes from the socket into the given buffer. | |
| vpr::ReturnStatus | recvn (std::vector< vpr::Uint8 > &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Receives exactly the specified number of bytes from the socket into the given buffer. | |
| virtual vpr::Uint32 | availableBytes () const |
| Returns the number of avaiable bytes for reading. | |
| vpr::ReturnStatus | send (const void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesWritten, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Sends the buffer to the remote side of the socket. | |
| vpr::ReturnStatus | send (const std::string &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesWritten, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Sends the buffer to the remote side of the socket. | |
| vpr::ReturnStatus | send (const std::vector< vpr::Uint8 > &buffer, const vpr::Uint32 length, vpr::Uint32 &bytesWritten, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Sends the buffer to the remote side of the socket. | |
| const vpr::SocketTypes::Type & | getType () const |
| Gets the type of this socket (e.g., vpr::SocketTypes::STREAM). | |
| const InetAddr & | getLocalAddr () const |
| vpr::ReturnStatus | setLocalAddr (const InetAddr &addr) |
| const InetAddr & | getRemoteAddr () const |
| vpr::ReturnStatus | setRemoteAddr (const InetAddr &addr) |
Public Attributes | |
| boost::shared_ptr< SocketImpl > | mSocketImpl |
| Platform-specific socket implementation object. | |
Protected Member Functions | |
| Socket_t () | |
| Default constructor. | |
| Socket_t (const std::string &address) | |
| Constructor. | |
| virtual | ~Socket_t () |
| Destructor. | |
| void | initSocket_t () |
| Helper function to capture code common between constructors. | |
| virtual vpr::ReturnStatus | read_i (void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the read() template method. | |
| virtual vpr::ReturnStatus | readn_i (void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesRead, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the readn() template method. | |
| virtual vpr::ReturnStatus | write_i (const void *buffer, const vpr::Uint32 length, vpr::Uint32 &bytesWritten, const vpr::Interval timeout=vpr::Interval::NoTimeout) |
| Implementation of the write() template method. | |
| virtual vpr::ReturnStatus | getOption (const vpr::SocketOptions::Types option, struct vpr::SocketOptions::Data &data) const |
| Retrieves the value for the given option as set on the socket. | |
| virtual vpr::ReturnStatus | setOption (const vpr::SocketOptions::Types option, const struct vpr::SocketOptions::Data &data) |
| Sets a value for the given option on the socket using the given data block. | |
vpr::Socket objects cannot be instantiated. Instead, see vpr::SocketStream and vpr::SocketDatagram. Given a SocketConfiguration declaration, this class is typedef'd to vpr::Socket.
| SockConfig_ | The SocketConfiguration type that matches the platform-specific socket implementation to use. |
Definition at line 84 of file Socket_t.h.
| typedef SockConfig_ vpr::Socket_t< SockConfig_ >::Config |
Reimplemented in vpr::SocketDatagram_t< SocketConfig_ >, and vpr::SocketStream_t< SocketConfig_ >.
Definition at line 87 of file Socket_t.h.
| typedef Config::SocketImpl vpr::Socket_t< SockConfig_ >::SocketImpl |
Definition at line 88 of file Socket_t.h.
| typedef Config::SocketIOStatsStrategy vpr::Socket_t< SockConfig_ >::DefaultIOStatsStrategy |
Definition at line 89 of file Socket_t.h.
| vpr::Socket_t< SockConfig_ >::Socket_t | ( | ) | [inline, protected] |
Default constructor.
The socket address is set to "INADDRY_ANY", and the implementation socket is initialized to NULL.
mSocketImpl is set to NULL. Definition at line 626 of file Socket_t.h.
00627 : vpr::BlockIO() 00628 { 00629 initSocket_t(); 00630 }
| vpr::Socket_t< SockConfig_ >::Socket_t | ( | const std::string & | address | ) | [inline, protected] |
Constructor.
The socket address is set to the given address, and the implementation socket is initialized to NULL.
mSocketImpl is set to NULL.| address | The address string for this socket object. |
Definition at line 642 of file Socket_t.h.
00643 : vpr::BlockIO(address) 00644 { 00645 initSocket_t(); 00646 }
| virtual vpr::Socket_t< SockConfig_ >::~Socket_t | ( | ) | [inline, protected, virtual] |
Destructor.
If the socket implementation object pointer is non-NULL, its memory is released.
Definition at line 655 of file Socket_t.h.
00656 { 00657 /* 00658 if(mSocketImpl != NULL) 00659 delete mSocketImpl; 00660 */ 00661 00662 //mSocketImpl = NULL; // Don't destory because it is a member of the child class 00663 // // it will get destroyed on it's own 00664 }
| virtual const std::string& vpr::Socket_t< SockConfig_ >::getName | ( | ) | const [inline, virtual] |
Gets the "name" of this socket.
It is typically the address of the peer host.
Reimplemented from vpr::BlockIO.
Definition at line 102 of file Socket_t.h.
00103 { 00104 return mSocketImpl->getName(); 00105 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::open | ( | ) | [inline, virtual] |
Opens the socket.
mOpen is set to true.vpr::ReturnStatus::Fail is returned otherwise.
Implements vpr::BlockIO.
Definition at line 119 of file Socket_t.h.
Referenced by vpr::SocketConnector::checkOpen(), and vpr::SocketAcceptor::open().
00120 { 00121 return mSocketImpl->open(); 00122 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::close | ( | ) | [inline, virtual] |
Closes the socket.
mOpen is set to false.vpr::ReturnStatus::Fail is returned otherwise.
Implements vpr::BlockIO.
Definition at line 136 of file Socket_t.h.
Referenced by vpr::SocketAcceptor::open().
00137 { 00138 return mSocketImpl->close(); 00139 }
| bool vpr::Socket_t< SockConfig_ >::isOpen | ( | ) | const [inline, virtual] |
Gets the open state of this socket.
Reimplemented from vpr::BlockIO.
Definition at line 151 of file Socket_t.h.
Referenced by vpr::SocketConnector::checkOpen(), vpr::SocketConnector::connectStart(), and vpr::SocketAcceptor::open().
00152 { 00153 return mSocketImpl->isOpen(); 00154 }
| bool vpr::Socket_t< SockConfig_ >::isBound | ( | ) | const [inline] |
Gets the bound state of this socket.
Definition at line 165 of file Socket_t.h.
Referenced by vpr::SocketConnector::connectStart().
00166 { 00167 return mSocketImpl->isBound(); 00168 }
| bool vpr::Socket_t< SockConfig_ >::isConnected | ( | ) | const [inline] |
Gets the status of a possibly connected socket.
true is returned if this socket is connected to a remote address.
false is returned if this socket is not currently connected (the other wise may have disconnected).
Definition at line 178 of file Socket_t.h.
Referenced by vpr::SocketConnector::complete().
00179 { 00180 return mSocketImpl->isConnected(); 00181 }
| vpr::IOSys::Handle vpr::Socket_t< SockConfig_ >::getHandle | ( | ) | const [inline, virtual] |
Gets the handle to this socket.
Implements vpr::BlockIO.
Definition at line 184 of file Socket_t.h.
Referenced by vpr::SocketConnector::complete().
00185 { 00186 return mSocketImpl->getHandle(); 00187 }
| bool vpr::Socket_t< SockConfig_ >::isBlockingFixed | ( | ) | const [inline] |
Queries if the blocking state for this socket is fixed and can no longer be changed.
Definition at line 193 of file Socket_t.h.
00194 { 00195 return mSocketImpl->isBlockingFixed(); 00196 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::setBlocking | ( | bool | blocking | ) | [inline, virtual] |
Reconfigures the socket so that it is in blocking or non-blocking mode depending on the value of the parameter.
If the socket has not been opened yet, it will be opened in blocking or non-blocking mode appropriately when open() is called.
| blocking | A value of true indicates that the socket should be configure to use blocking I/O. A value of false indicates that it should use non-blocking I/O. |
Implements vpr::BlockIO.
Definition at line 214 of file Socket_t.h.
Referenced by vpr::SocketConnector::connectStart().
00215 { 00216 return mSocketImpl->setBlocking(blocking); 00217 }
| bool vpr::Socket_t< SockConfig_ >::isBlocking | ( | ) | const [inline, virtual] |
Gets the current blocking state for the socket.
Reimplemented from vpr::BlockIO.
Definition at line 228 of file Socket_t.h.
Referenced by vpr::SocketConnector::complete().
00229 { 00230 return mSocketImpl->isBlocking(); 00231 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::bind | ( | ) | [inline] |
Binds this socket to the address in the host address member variable.
vpr::ReturnStatus::Fail is returned otherwise.
Definition at line 243 of file Socket_t.h.
Referenced by vpr::SocketConnector::connectStart(), and vpr::SocketAcceptor::open().
00244 { 00245 return mSocketImpl->bind(); 00246 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::connect | ( | const vpr::Interval | timeout = vpr::Interval::NoTimeout |
) | [inline] |
Connects the socket on the client side to the server side.
For a datagram socket, this makes the address given to the constructor the default destination for all packets. For a stream socket, this has the effect of establishing a connection with the destination.
mLocalAddr. For a stream socket, this means that a connection for future communication has been established. For a datagram socket, the default destination for all packets is now mLocalAddr.vpr::ReturnStatus::InProgress is returned if this is a non-blocking socket and the connection is still in progress. The connection will be completed "in the background".
vpr::ReturnStatus::Timeout is returned if the connection could not be made within the given timeout interval.
vpr::ReturnStatus::Fail is returned if the connection could not be made.
Definition at line 274 of file Socket_t.h.
Referenced by vpr::SocketConnector::connect().
00275 { 00276 return mSocketImpl->connect(timeout); 00277 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recv | ( | void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives at most the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer where the socket's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the read operation failed.
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to receive.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
Definition at line 305 of file Socket_t.h.
00308 { 00309 return read(buffer, length, bytesRead, timeout); 00310 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recv | ( | std::string & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives at most the specified number of bytes from the socket into the given buffer.
| buffer | A reference to the buffer (a std::string object) where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the read operation failed.
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to receive.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
Definition at line 339 of file Socket_t.h.
00342 { 00343 return read(buffer, length, bytesRead, timeout); 00344 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recv | ( | std::vector< vpr::Uint8 > & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives at most the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer (a vector of chars) where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the read operation failed.
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to receive.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
Definition at line 373 of file Socket_t.h.
00376 { 00377 return read(buffer, length, bytesRead, timeout); 00378 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recvn | ( | void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives exactly the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the read operation failed.
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to receive.
Definition at line 404 of file Socket_t.h.
00407 { 00408 return readn(buffer, length, bytesRead, timeout); 00409 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recvn | ( | std::string & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives exactly the specified number of bytes from the socket into the given buffer.
| buffer | A reference to the buffer (a std::string object) where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
Definition at line 437 of file Socket_t.h.
00440 { 00441 return readn(buffer, length, bytesRead, timeout); 00442 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::recvn | ( | std::vector< vpr::Uint8 > & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Receives exactly the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer (a vector of chars) where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the read operation failed.
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to receive.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
Definition at line 471 of file Socket_t.h.
00474 { 00475 return readn(buffer, length, bytesRead, timeout); 00476 }
| virtual vpr::Uint32 vpr::Socket_t< SockConfig_ >::availableBytes | ( | ) | const [inline, virtual] |
Returns the number of avaiable bytes for reading.
Reimplemented from vpr::BlockIO.
Definition at line 479 of file Socket_t.h.
00480 { 00481 return mSocketImpl->availableBytes(); 00482 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::send | ( | const void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesWritten, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Sends the buffer to the remote side of the socket.
| buffer | A pointer to the buffer to be written. | |
| length | The length of the buffer. | |
| bytesWritten | The number of bytes written to the device. | |
| timeout | The maximum amount of time to wait for data to be available for writing. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the write operation failed.
vpr::ReturnStatus::WouldBlock is returned if the handle is in non-blocking mode, and the write operation could not be completed.
vpr::ReturnStatus::Timeout is returned if the write could not begin within the timeout interval.
Definition at line 509 of file Socket_t.h.
00512 { 00513 return write(buffer, length, bytesWritten, timeout); 00514 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::send | ( | const std::string & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesWritten, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Sends the buffer to the remote side of the socket.
| buffer | A reference to the buffer (a std::string object) to be written. | |
| length | The length of the buffer. | |
| bytesWritten | The number of bytes written to the device. | |
| timeout | The maximum amount of time to wait for data to be available for writing. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the write operation failed.
vpr::ReturnStatus::WouldBlock is returned if the handle is in non-blocking mode, and the send operation could not be completed.
vpr::ReturnStatus::Timeout is returned if the write could not begin within the timeout interval.
Definition at line 541 of file Socket_t.h.
00544 { 00545 vprASSERT(length <= buffer.size() && "length was bigger than the data given"); 00546 return write(buffer, length, bytesWritten, timeout); 00547 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::send | ( | const std::vector< vpr::Uint8 > & | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesWritten, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline] |
Sends the buffer to the remote side of the socket.
| buffer | A reference to the buffer (a std::string object) to be written. | |
| length | The length of the buffer. | |
| bytesWritten | The number of bytes written to the device. | |
| timeout | The maximum amount of time to wait for data to be available for writing. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::Fail is returned if the write operation failed.
vpr::ReturnStatus::WoudlBlock is returned if the handle is in non-blocking mode, and the send operation could not be completed.
vpr::ReturnStatus::Timeout is returned if the write could not begin within the timeout interval.
Definition at line 574 of file Socket_t.h.
00578 { 00579 vprASSERT(length <= buffer.size() && "length was bigger than the data given"); 00580 return write(buffer, length, bytesWritten,timeout); 00581 }
| const vpr::SocketTypes::Type& vpr::Socket_t< SockConfig_ >::getType | ( | ) | const [inline] |
Gets the type of this socket (e.g., vpr::SocketTypes::STREAM).
mSocketImpl is returned to the caller.Definition at line 592 of file Socket_t.h.
00593 { 00594 return mSocketImpl->getType(); 00595 }
| const InetAddr& vpr::Socket_t< SockConfig_ >::getLocalAddr | ( | ) | const [inline] |
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::setLocalAddr | ( | const InetAddr & | addr | ) | [inline] |
Definition at line 602 of file Socket_t.h.
Referenced by vpr::SocketConnector::connectStart(), and vpr::SocketAcceptor::open().
00603 { 00604 return mSocketImpl->setLocalAddr(addr); 00605 }
| const InetAddr& vpr::Socket_t< SockConfig_ >::getRemoteAddr | ( | ) | const [inline] |
Definition at line 607 of file Socket_t.h.
00608 { 00609 return mSocketImpl->getRemoteAddr(); 00610 }
| vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::setRemoteAddr | ( | const InetAddr & | addr | ) | [inline] |
Definition at line 612 of file Socket_t.h.
Referenced by vpr::SocketConnector::connect().
00613 { 00614 return mSocketImpl->setRemoteAddr(addr); 00615 }
| void vpr::Socket_t< SockConfig_ >::initSocket_t | ( | ) | [inline, protected] |
Helper function to capture code common between constructors.
Definition at line 669 of file Socket_t.h.
Referenced by vpr::Socket_t< SocketConfig_ >::Socket_t().
00670 { 00671 // Allocate stats stategy object. 00672 // First, use template programming magic. If the stategy is the null 00673 // one, then don't allocate one. 00674 // NOTE: Because all the info is static the compiler "should" optimize 00675 // the following if statement away. 00676 if( DefaultIOStatsStrategy::IS_NULL == 0) // If we have a real one 00677 { 00678 //std::cout << "Allocating strategy: " << typeid(DefaultIOStatsStrategy).name() << std::endl; 00679 BaseIOStatsStrategy* new_strategy = new DefaultIOStatsStrategy; 00680 this->setIOStatStrategy(new_strategy); 00681 } 00682 }
| virtual vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::read_i | ( | void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline, protected, virtual] |
Implementation of the read() template method.
This reads at most the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to read.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
vpr::ReturnStatus::Fail is returned if the read operation failed.
Implements vpr::BlockIO.
Definition at line 711 of file Socket_t.h.
00714 { 00715 return mSocketImpl->read_i(buffer, length, bytesRead, timeout); 00716 }
| virtual vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::readn_i | ( | void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesRead, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline, protected, virtual] |
Implementation of the readn() template method.
This reads exactly the specified number of bytes from the socket into the given buffer.
| buffer | A pointer to the buffer where the device's buffer contents are to be stored. | |
| length | The number of bytes to be read. | |
| bytesRead | The number of bytes read into the buffer. | |
| timeout | The maximum amount of time to wait for data to be available for reading. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::WouldBlock if the device is in non-blocking mode, and there is no data to read.
vpr::ReturnStatus::Timeout is returned if the read could not begin within the timeout interval.
vpr::ReturnStatus::Fail is returned if the read operation failed.
Implements vpr::BlockIO.
Definition at line 745 of file Socket_t.h.
00748 { 00749 return mSocketImpl->readn_i(buffer, length, bytesRead, timeout); 00750 }
| virtual vpr::ReturnStatus vpr::Socket_t< SockConfig_ >::write_i | ( | const void * | buffer, | |
| const vpr::Uint32 | length, | |||
| vpr::Uint32 & | bytesWritten, | |||
| const vpr::Interval | timeout = vpr::Interval::NoTimeout | |||
| ) | [inline, protected, virtual] |
Implementation of the write() template method.
This writes the buffer to the socket.
| buffer | A pointer to the buffer to be written. | |
| length | The length of the buffer. | |
| bytesWritten | The number of bytes written to the device. | |
| timeout | The maximum amount of time to wait for data to be available for writing. This argument is optional and defaults to vpr::Interval::NoTimeout. |
vpr::ReturnStatus::WouldBlock is returned if the handle is in non-blocking mode, and the write could not be completed.
vpr::ReturnStatus::Timeout is returned if the write could not begin within the timeout interval.
vpr::ReturnStatus::Fail is returned if the write operation failed.
Implements vpr::BlockIO.
Definition at line 777 of file Socket_t.h.
00781 { 00782 return mSocketImpl->write_i(buffer, length, bytesWritten, timeout); 00783 }
| virtual vpr::ReturnStatus vpr::Soc |