TcpSocketBase class
A TCP socket of the given IP version, on a plain or an asynchronous socket.
On this page
- Use
import ThinkMeta.ConcurrentTasks.Net.TcpSocket;- Namespace
ThinkMeta::ConcurrentTasks::Net- Inherits
IpSocketBase- Platforms
- Windows, Linux
Syntax
template <IpVersionType _IpVersion, SocketType _BaseSocket>
class TcpSocketBase : public IpSocketBase<_IpVersion, _BaseSocket>Template parameters
_IpVersionIpVersionType- The IP version:
IpVersion::V4orIpVersion::V6. _BaseSocketSocketType- The socket class built on:
Platform::Socket(blocking calls) orAsyncIo::AsyncSocket.
Remarks
Adds the TCP form of Create and the TCP options to IpSocketBase. Owns its socket like Socket.
See also
TcpSocket, AsyncIo::AsyncTcpSocket
Names
| Name | Description |
|---|---|
TcpSocket |
A blocking (plain Platform::Socket) TCP socket of the given IP version.
|
TcpSocket4 |
A blocking TCP socket over IPv4. |
TcpSocket6 |
A blocking TCP socket over IPv6. |
Constructors
TcpSocketBase
Takes over other's socket; other is left without one.
Syntax
TcpSocketBase(TcpSocketBase&& other) noexcept = default;Parameters
otherTcpSocketBase&&- The object whose socket is taken over; it holds no socket afterwards.
Methods
operator=
Takes over other's socket; a socket this object already holds is closed first.
Syntax
TcpSocketBase& operator=(TcpSocketBase&& other) noexcept = default;Parameters
otherTcpSocketBase&&- The object whose socket is taken over; it holds no socket afterwards.
Return value
Type: TcpSocketBase&
This object.
Create
Windows only
Creates a TCP socket of the IP version (SOCK_STREAM, IPPROTO_TCP).
Syntax
SocketErrorCode Create(
WSAPROTOCOL_INFO* protocolInfo = nullptr,
GROUP g = 0,
DWORD flags = 0
) noexcept;Parameters
protocolInfoWSAPROTOCOL_INFO*- Optional
WSAPROTOCOL_INFOselecting the provider;nullptrfor the default.Default:nullptr gGROUP- The Winsock socket group;
0for none.Default:0 flagsDWORD- Further
WSA_FLAG_*flags;0for none.Default:0
Return value
Type: SocketErrorCode
Platform::SocketError::Success, or the error of creating the socket.
Linux only
Creates a TCP socket of the IP version (SOCK_STREAM, IPPROTO_TCP).
Syntax
SocketErrorCode Create() noexcept;Return value
Type: SocketErrorCode
Platform::SocketError::Success, or the error of creating the socket.
SetOptionNoDelay
Sets TCP_NODELAY: send small segments at once instead of waiting to fill them (Nagle off).
Syntax
SocketErrorCode SetOptionNoDelay(bool noDelay) noexcept;Parameters
noDelaybooltrueto send at once,falsefor the default (Nagle's algorithm).
Return value
Type: SocketErrorCode
Platform::SocketError::Success, or the error of setsockopt.
GetOptionNoDelay
Gets the TCP_NODELAY setting.
Syntax
SocketErrorCode GetOptionNoDelay(bool* noDelay) noexcept;Parameters
noDelaybool*- Required. Receives
trueif Nagle's algorithm is off.
Return value
Type: SocketErrorCode
Platform::SocketError::Success, or the error of getsockopt.
Types
SockAddr
The socket address type of the IP version (sockaddr_in or sockaddr_in6).
Syntax
using SockAddr = typename _Traits::SockAddr;Generated from ThinkMeta.ConcurrentTasks.API @ da816bc (2026-11-06).