DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
TcpClient.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "Common.h"
9#include "System/Object.h"
10#include "System/String.h"
11#include "System/SmartPointer.h"
14
15namespace DotNetDupe {
16 namespace System {
17 namespace Net {
18 namespace Sockets {
19
25 class TcpClient : public Object {
26 public:
29
32 DOTNETDUPE_API explicit TcpClient(AddressFamily family);
33
36 DOTNETDUPE_API explicit TcpClient(const SmartPointer<Socket>& socket);
37
40
41 TcpClient(const TcpClient&) = delete;
42 TcpClient& operator=(const TcpClient&) = delete;
43 DOTNETDUPE_API TcpClient(TcpClient&& other) noexcept;
45
49 DOTNETDUPE_API void Connect(const String& ip, int port);
50
55
57 DOTNETDUPE_API void Close();
58
61 DOTNETDUPE_API bool Connected() const;
62
66
70
71 private:
72 SmartPointer<Socket> m_pClientSocket;
73 SmartPointer<NetworkStream> m_pNetworkStream;
74 };
75
76 }
77 }
78 }
79}
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Provides the underlying stream of data for network access.
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
Implements the Berkeley sockets interface for network communications.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
void Close()
Disposes this TcpClient instance and closes the underlying connection.
Definition TcpClient.cpp:65
void SetClient(const SmartPointer< Socket > &socket)
Sets the underlying Socket.
Definition TcpClient.cpp:85
TcpClient()
Initializes a new instance of the TcpClient class with AddressFamily::InterNetwork.
Definition TcpClient.cpp:10
SmartPointer< NetworkStream > GetStream()
Returns the NetworkStream used to send and receive data.
Definition TcpClient.cpp:52
SmartPointer< Socket > GetClient() const
Gets the underlying Socket.
Definition TcpClient.cpp:81
void Connect(const String &ip, int port)
Connects the client to a remote TCP host using the specified IP address and port number.
Definition TcpClient.cpp:42
TcpClient & operator=(const TcpClient &)=delete
bool Connected() const
Gets a value indicating whether the underlying Socket for a TcpClient is connected to a remote host.
Definition TcpClient.cpp:77
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
AddressFamily
Specifies the addressing scheme that an instance of the Socket class can use.
Definition Socket.h:20