Socket.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/network/virtual_/Socket.hpp"

Socket

Virtual socket implementation. Can be used as a bidirectional data transfer between different threads of the same process.
Under the hood it uses a pair of oatpp::network::virtual_::Pipe. One to write data to, and one to read data from. Extends oatpp::base::Countable and oatpp::data::stream::IOStream.

namespace oatpp { namespace network { namespace virtual_ { 
  class Socket : public oatpp::data::stream::IOStream, public oatpp::base::Countable {}
}}}

Methods

Return Type Name Summary
[none] Socket Constructor.
std::shared_ptr<Socket> createShared Create shared socket.
[none] ~Socket Virtual destructor. Close corresponding pipes.
void setMaxAvailableToReadWrtie Limit the available amount of bytes to read from socket and limit the available amount of bytes to write to socket.
data::v_io_size read Read data from socket.
data::v_io_size write Write data to socket.
oatpp::async::Action suggestOutputStreamAction Implementation of OutputStream must suggest async actions for I/O results.
oatpp::async::Action suggestInputStreamAction Implementation of InputStream must suggest async actions for I/O results.
void setOutputStreamIOMode Set OutputStream I/O mode.
oatpp::data::stream::IOMode getOutputStreamIOMode Set OutputStream I/O mode.
void setInputStreamIOMode Set InputStream I/O mode.
oatpp::data::stream::IOMode getInputStreamIOMode Get InputStream I/O mode.
void close Close socket pipes.

Socket::Socket

Constructor.

  • @param pipeIn - pipe to read data from.
  • @param pipeOut - pipe to write data to.

Socket(const std::shared_ptr<Pipe>& pipeIn, const std::shared_ptr<Pipe>& pipeOut)

Socket::createShared

Create shared socket.

  • @param pipeIn - pipe to read data from.
  • @param pipeOut - pipe to write data to.
  • @return - std::shared_ptr to Socket.

static std::shared_ptr<Socket> createShared(const std::shared_ptr<Pipe>& pipeIn, const std::shared_ptr<Pipe>& pipeOut)

Socket::~Socket

Virtual destructor. Close corresponding pipes.

~Socket()

Socket::setMaxAvailableToReadWrtie

Limit the available amount of bytes to read from socket and limit the available amount of bytes to write to socket.
This method is used for testing purposes only.

  • @param maxToRead - maximum available amount of bytes to read.
  • @param maxToWrite - maximum available amount of bytes to write.

void setMaxAvailableToReadWrtie(data::v_io_size maxToRead, data::v_io_size maxToWrite)

Socket::read

Read data from socket.

  • @param data - buffer to read data to.
  • @param count - buffer size.
  • @return - actual amount of data read from socket.

data::v_io_size read(void *data, data::v_io_size count) override

Socket::write

Write data to socket.

  • @param data - data to write to socket.
  • @param count - data size.
  • @return - actual amount of data written to socket.

data::v_io_size write(const void *data, data::v_io_size count) override

Socket::suggestOutputStreamAction

Implementation of OutputStream must suggest async actions for I/O results. Suggested Action is used for scheduling coroutines in async::Executor.

oatpp::async::Action suggestOutputStreamAction(data::v_io_size ioResult) override

Socket::suggestInputStreamAction

Implementation of InputStream must suggest async actions for I/O results. Suggested Action is used for scheduling coroutines in async::Executor.

oatpp::async::Action suggestInputStreamAction(data::v_io_size ioResult) override

Socket::setOutputStreamIOMode

Set OutputStream I/O mode.

  • @param ioMode

void setOutputStreamIOMode(oatpp::data::stream::IOMode ioMode) override

Socket::getOutputStreamIOMode

Set OutputStream I/O mode.

  • @return

oatpp::data::stream::IOMode getOutputStreamIOMode() override

Socket::setInputStreamIOMode

Set InputStream I/O mode.

  • @param ioMode

void setInputStreamIOMode(oatpp::data::stream::IOMode ioMode) override

Socket::getInputStreamIOMode

Get InputStream I/O mode.

  • @return

oatpp::data::stream::IOMode getInputStreamIOMode() override

Socket::close

Close socket pipes.

void close()