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/base/nullability.h>
14
15#include "absl/status/status.h"
16#include "absl/status/statusor.h"
17#include "absl/time/time.h"
18
20
21struct NativeTcpClient;
22class TcpListener;
23class ActiveTcpListener;
24
33class TcpClient {
34 public:
41 static absl::StatusOr<TcpClient> ConnectIpv4(
42 std::array<std::uint8_t, 4> address, std::uint16_t port,
43 absl::Time deadline = absl::InfiniteFuture());
44
50 static absl::StatusOr<TcpClient> ConnectHost(
51 std::string_view hostname, std::uint16_t port,
52 absl::Time deadline = absl::InfiniteFuture());
53
54 TcpClient(TcpClient&& other) noexcept;
55 TcpClient& operator=(TcpClient&& other) noexcept;
56 TcpClient(const TcpClient&) = delete;
57 TcpClient& operator=(const TcpClient&) = delete;
58 ~TcpClient();
59
61 void Close();
62
64 absl::Status SetNoDelay(bool enabled = true);
65
74 absl::Status Send(std::span<const std::uint8_t> bytes,
75 absl::Time deadline = absl::InfiniteFuture());
76
84 absl::StatusOr<std::size_t> Receive(
85 std::span<std::uint8_t> bytes,
86 absl::Time deadline = absl::InfiniteFuture());
87
88 private:
89 friend class TcpListener;
90 friend class ActiveTcpListener;
91
92 explicit TcpClient(NativeTcpClient* absl_nonnull native) : native_(native) {}
93
94 NativeTcpClient* absl_nullable native_ = nullptr;
95};
96
97} // namespace symbian::api::connectivity
98
99#endif // SYMBIAN_API_CONNECTIVITY_TCP_CLIENT_H_
A single pending RSocket accept managed by a Symbian active scheduler.
Definition active_tcp_listener.h:36
One connected IPv4 TCP stream backed by Symbian RSocket.
Definition tcp_client.h:33
absl::Status SetNoDelay(bool enabled=true)
Disable Nagle buffering for interactive message transports.
Definition tcp_client.cc:90
~TcpClient()
Definition tcp_client.cc:82
TcpClient(const TcpClient &)=delete
TcpClient & operator=(const TcpClient &)=delete
TcpClient & operator=(TcpClient &&other) noexcept
Definition tcp_client.cc:74
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:98
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:26
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:116
void Close()
Close on the owner thread; repeated calls are harmless.
Definition tcp_client.cc:86
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:45
One bounded IPv4 listener backed by Symbian RSocket.
Definition tcp_listener.h:30
GLint enabled
Definition gles2_frame_backend.cc:62
Definition active_tcp_listener.cc:13
uint32_t address
Definition exports.cc:71
std::string_view bytes
Definition exports.cc:76
Definition native_tcp_client.cc:20