DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
UdpClient.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"
13
14namespace DotNetDupe {
15 namespace System {
16 namespace Net {
17 namespace Sockets {
18
24 class UdpClient : public Object {
25 public:
28
31 DOTNETDUPE_API explicit UdpClient(int port);
32
36 DOTNETDUPE_API UdpClient(const String& ip, int port);
37
40
41 UdpClient(const UdpClient&) = delete;
42 UdpClient& operator=(const UdpClient&) = delete;
43 DOTNETDUPE_API UdpClient(UdpClient&& other) noexcept;
45
49 DOTNETDUPE_API void Connect(const String& ip, int port);
50
57 DOTNETDUPE_API int Send(const char* buffer, int offset, int size);
58
67 DOTNETDUPE_API int Send(const char* buffer, int offset, int size, const String& ip, int port);
68
77 DOTNETDUPE_API int Receive(char* buffer, int offset, int size, String& ip, int& port);
78
80 DOTNETDUPE_API void Close();
81
85
86 private:
87 SmartPointer<Socket> m_pClientSocket;
88 };
89
90 }
91 }
92 }
93}
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
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.
int Receive(char *buffer, int offset, int size, String &ip, int &port)
Returns a UDP datagram that was sent by a remote host.
Definition UdpClient.cpp:72
void Connect(const String &ip, int port)
Establishes a default remote host using the specified IP address and port number.
Definition UdpClient.cpp:42
UdpClient & operator=(const UdpClient &)=delete
UdpClient()
Initializes a new instance of the UdpClient class.
Definition UdpClient.cpp:10
int Send(const char *buffer, int offset, int size)
Sends a UDP datagram to a remote host (used when Connect has established default host).
Definition UdpClient.cpp:52
SmartPointer< Socket > GetClient() const
Gets the underlying network Socket.
Definition UdpClient.cpp:90
void Close()
Closes the UDP connection.
Definition UdpClient.cpp:82
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