Implemented tcp sockets (only IPv4) and asynchronous IO (for sockets).

This commit is contained in:
2024-08-16 21:29:33 +02:00
parent da348c1f40
commit f0d0ee17ea
7 changed files with 758 additions and 38 deletions

View File

@@ -53,7 +53,7 @@ int ProcessStream::close()
return result;
}
StreamError ProcessStream::readRaw(std::span<std::uint8_t> buffer, bool partial, std::size_t* outBytesRead)
StreamError ProcessStream::readRaw(std::span<std::uint8_t> buffer, const ReadOptions& options, std::size_t* outBytesRead)
{
assert(handle);
assert(mode == FileOpenMode::READ || mode == FileOpenMode::READ_WRITE);
@@ -67,7 +67,7 @@ StreamError ProcessStream::readRaw(std::span<std::uint8_t> buffer, bool partial,
if (std::ferror(handle)) {
return StreamError::IO_ERROR;
}
if (!partial && readBytes < buffer.size()) {
if (!options.partial && readBytes < buffer.size()) {
return StreamError::IO_ERROR;
}
if (outBytesRead != nullptr)
@@ -134,7 +134,10 @@ StreamFeatures ProcessStream::getFeatures()
.read = (mode == FileOpenMode::READ),
.write = (mode == FileOpenMode::WRITE || mode == FileOpenMode::READ_WRITE),
.tell = true,
.seek = false
.seek = false,
.readOptions = {
.partial = true
}
};
}
return {};