|
std::unique_ptr< Socket > | accept (uint32_t timeoutMs) override |
| Accepts next connection from listening socket, with a timeout.
|
|
std::unique_ptr< Socket > | accept () override |
| Accepts next connection from listening socket.
|
|
void | listen () override |
| Configures the socket to listen for incoming connections.
|
|
int | read (void *buffer, std::size_t bufferSize) override |
| Reads bytes from the socket.
|
|
int | write (const void *buffer, std::size_t len) override |
| Write bytes to the socket.
|
|
std::uint16_t | getPort () const override |
| Returns port of the socket.
|
|
void | setNonBlocking () override |
| Sets the socket to non-blocking mode.
|
|
|
std::uint16_t | port |
|
std::atomic_bool | acceptReady |
|
std::deque< tenduke::osa::Socket * > | acceptedSockets |
|
std::vector< std::string > | writtenData |
|
std::string | readData |
|
◆ accept() [1/2]
std::unique_ptr<::Socket > tenduke::test::fakes::FakeSocket::accept |
( |
| ) |
|
|
overridevirtual |
Accepts next connection from listening socket.
No timeout.
- Returns
- the child socket
Implements tenduke::osa::Socket.
◆ accept() [2/2]
std::unique_ptr<::Socket > tenduke::test::fakes::FakeSocket::accept |
( |
uint32_t |
timeoutMs | ) |
|
|
overridevirtual |
Accepts next connection from listening socket, with a timeout.
The socket must be set to listening mode using listen()
before calling this method. New connection is returned as new tenduke::osa::Socket
. This method times out after timeoutMs
milliseconds and then returns nullptr
.
IMPORTANT NOTE: When using timeout, you should call setNonBlocking()
on the socket to avoid race conditions.
- Parameters
-
timeoutMs | timeout in milliseconds. Zero timeout is not yet supported. |
- Returns
- the child socket or
nullptr
if accept timed out
- Exceptions
-
Implements tenduke::osa::Socket.
◆ getPort()
uint16_t tenduke::test::fakes::FakeSocket::getPort |
( |
| ) |
const |
|
overridevirtual |
◆ listen()
void tenduke::test::fakes::FakeSocket::listen |
( |
| ) |
|
|
overridevirtual |
Configures the socket to listen for incoming connections.
- Exceptions
-
Implements tenduke::osa::Socket.
◆ read()
int tenduke::test::fakes::FakeSocket::read |
( |
void * |
buffer, |
|
|
std::size_t |
bufferSize |
|
) |
| |
|
overridevirtual |
Reads bytes from the socket.
- Parameters
-
buffer | buffer where the bytes are placed to |
bufferSize | size of the buffer in bytes |
- Returns
- number of bytes read. Returns -1, if socket is non-blocking and nothing to read yet.
- Exceptions
-
Implements tenduke::osa::Socket.
◆ setNonBlocking()
void tenduke::test::fakes::FakeSocket::setNonBlocking |
( |
| ) |
|
|
overridevirtual |
◆ write()
int tenduke::test::fakes::FakeSocket::write |
( |
const void * |
buffer, |
|
|
std::size_t |
len |
|
) |
| |
|
overridevirtual |
Write bytes to the socket.
- Parameters
-
buffer | these bytes are written |
len | number of bytes to write |
- Returns
- number of bytes written
- Exceptions
-
Implements tenduke::osa::Socket.
The documentation for this class was generated from the following files:
- core/oidc/osbrowser/test/fakes/FakeSocket.h
- core/oidc/osbrowser/test/fakes/FakeSocket.cpp