Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
tcp_client.h
Go to the documentation of this file.
1// Copyright 2026 The Symbian SDK Authors.
2// Licensed under the Apache License, Version 2.0.
3
4#ifndef SYMBIAN_API_CONNECTIVITY_TCP_CLIENT_H_
5#define SYMBIAN_API_CONNECTIVITY_TCP_CLIENT_H_
6
7#include <array>
8#include <cstddef>
9#include <cstdint>
10#include <span>
11#include <string_view>
12
13#include "absl/status/status.h"
14#include "absl/status/statusor.h"
15#include "absl/time/time.h"
16
18
19struct NativeTcpClient;
20class TcpListener;
21class ActiveTcpListener;
22
31class TcpClient {
32 public:
39 static absl::StatusOr<TcpClient> ConnectIpv4(
40 std::array<std::uint8_t, 4> address, std::uint16_t port,
41 absl::Time deadline = absl::InfiniteFuture());
42
48 static absl::StatusOr<TcpClient> ConnectHost(
49 std::string_view hostname, std::uint16_t port,
50 absl::Time deadline = absl::InfiniteFuture());
51
52 TcpClient(TcpClient&& other) noexcept;
53 TcpClient& operator=(TcpClient&& other) noexcept;
54 TcpClient(const TcpClient&) = delete;
55 TcpClient& operator=(const TcpClient&) = delete;
56 ~TcpClient();
57
59 void Close();
60
62 absl::Status SetNoDelay(bool enabled = true);
63
72 absl::Status Send(std::span<const std::uint8_t> bytes,
73 absl::Time deadline = absl::InfiniteFuture());
74
82 absl::StatusOr<std::size_t> Receive(
83 std::span<std::uint8_t> bytes,
84 absl::Time deadline = absl::InfiniteFuture());
85
86 private:
87 friend class TcpListener;
88 friend class ActiveTcpListener;
89
90 explicit TcpClient(NativeTcpClient* native) : native_(native) {}
91
92 NativeTcpClient* native_ = nullptr;
93};
94
95} // namespace symbian::api::connectivity
96
97#endif // SYMBIAN_API_CONNECTIVITY_TCP_CLIENT_H_
A single pending RSocket accept managed by a Symbian active scheduler.
Definition active_tcp_listener.h:40
One connected IPv4 TCP stream backed by Symbian RSocket.
Definition tcp_client.h:31
absl::Status SetNoDelay(bool enabled=true)
Disable Nagle buffering for interactive message transports.
Definition tcp_client.cc:89
~TcpClient()
Definition tcp_client.cc:81
TcpClient(const TcpClient &)=delete
TcpClient & operator=(const TcpClient &)=delete
TcpClient & operator=(TcpClient &&other) noexcept
Definition tcp_client.cc:73
absl::Status Send(std::span< const std::uint8_t > bytes, absl::Time deadline=absl::InfiniteFuture())
Complete one native send request of at most 32 KiB by a deadline.
Definition tcp_client.cc:97
static absl::StatusOr< TcpClient > ConnectIpv4(std::array< std::uint8_t, 4 > address, std::uint16_t port, absl::Time deadline=absl::InfiniteFuture())
Connect to four IPv4 octets by an absolute deadline.
Definition tcp_client.cc:25
absl::StatusOr< std::size_t > Receive(std::span< std::uint8_t > bytes, absl::Time deadline=absl::InfiniteFuture())
Receive at least one byte into a buffer of at most 32 KiB.
Definition tcp_client.cc:115
void Close()
Close on the owner thread; repeated calls are harmless.
Definition tcp_client.cc:85
static absl::StatusOr< TcpClient > ConnectHost(std::string_view hostname, std::uint16_t port, absl::Time deadline=absl::InfiniteFuture())
Resolve an ASCII DNS hostname and connect by one deadline.
Definition tcp_client.cc:44
One bounded IPv4 listener backed by Symbian RSocket.
Definition tcp_listener.h:28
Definition active_tcp_listener.cc:11
uint32_t address
Definition exports.cc:69
std::string_view bytes
Definition exports.cc:74
Definition native_tcp_client.cc:19