CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
tcp_client.h
1
2#pragma once
3
4#include <system/shared_ptr.h>
5#include <system/idisposable.h>
6
7#include <net/sockets/socket.h>
8#include <net/sockets/network_stream.h>
9#include <net/ip_end_point.h>
10
11namespace System {
12namespace Net {
13namespace Sockets {
14
19class ASPOSECPP_SHARED_CLASS TcpClient : public System::IDisposable
20{
22 typedef TcpClient ThisType;
25
27 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
29 ASPOSECPP_SHARED_RTTI_INFO_DECL();
30
31public:
34 ASPOSECPP_SHARED_API System::SharedPtr<Socket> get_Client();
37 ASPOSECPP_SHARED_API void set_Client(System::SharedPtr<Socket> value);
40 ASPOSECPP_SHARED_API int32_t get_Available();
43 ASPOSECPP_SHARED_API bool get_Connected();
46 ASPOSECPP_SHARED_API bool get_ExclusiveAddressUse();
49 ASPOSECPP_SHARED_API void set_ExclusiveAddressUse(bool value);
52 ASPOSECPP_SHARED_API int32_t get_ReceiveBufferSize();
55 ASPOSECPP_SHARED_API void set_ReceiveBufferSize(int32_t value);
58 ASPOSECPP_SHARED_API int32_t get_SendBufferSize();
61 ASPOSECPP_SHARED_API void set_SendBufferSize(int32_t value);
64 ASPOSECPP_SHARED_API int32_t get_ReceiveTimeout();
67 ASPOSECPP_SHARED_API void set_ReceiveTimeout(int32_t value);
70 ASPOSECPP_SHARED_API int32_t get_SendTimeout();
73 ASPOSECPP_SHARED_API void set_SendTimeout(int32_t value);
79 ASPOSECPP_SHARED_API void set_LingerState(System::SharedPtr<LingerOption> value);
82 ASPOSECPP_SHARED_API bool get_NoDelay();
85 ASPOSECPP_SHARED_API void set_NoDelay(bool value);
86
89 ASPOSECPP_SHARED_API TcpClient(System::SharedPtr<IPEndPoint> localEP);
91 ASPOSECPP_SHARED_API TcpClient();
94 ASPOSECPP_SHARED_API TcpClient(AddressFamily family);
98 ASPOSECPP_SHARED_API TcpClient(String hostname, int32_t port);
99
103 ASPOSECPP_SHARED_API void Connect(String hostname, int32_t port);
107 ASPOSECPP_SHARED_API void Connect(System::SharedPtr<IPAddress> address, int32_t port);
110 ASPOSECPP_SHARED_API void Connect(System::SharedPtr<IPEndPoint> remoteEP);
114 ASPOSECPP_SHARED_API void Connect(System::ArrayPtr<System::SharedPtr<IPAddress>> ipAddresses, int32_t port);
121 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult> BeginConnect(String host, int32_t port, AsyncCallback requestCallback, System::SharedPtr<Object> state);
138 ASPOSECPP_SHARED_API void EndConnect(System::SharedPtr<IAsyncResult> asyncResult);
143 ASPOSECPP_SHARED_API void Close();
144
146 virtual ASPOSECPP_SHARED_API ~TcpClient();
147};
148} // namespace Sockets
149} // namespace Net
150} // namespace System
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Represents a client for the TCP network services. Objects of this class should only be allocated usin...
Definition: tcp_client.h:20
TcpClient(String hostname, int32_t port)
Constructs a new instance.
System::SharedPtr< LingerOption > get_LingerState()
Gets a value that indicates if the socket will delay closing in an attempt to send all pending data.
void set_ExclusiveAddressUse(bool value)
Sets a value that indicates if the current instance allows only one client to use a port.
TcpClient(AddressFamily family)
Constructs a new instance.
int32_t get_ReceiveBufferSize()
Gets the size of the buffer that is used for receiving data.
int32_t get_ReceiveTimeout()
Gets a value that indicates an amount of time after which data receiving will time out.
System::SharedPtr< IAsyncResult > BeginConnect(String host, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
int32_t get_Available()
Returns the number of bytes that are received and ready to read.
int32_t get_SendBufferSize()
Gets the size of the buffer that is used for sending data.
void set_LingerState(System::SharedPtr< LingerOption > value)
Sets a value that indicates if the socket will delay closing in an attempt to send all pending data.
void Connect(String hostname, int32_t port)
Establishes a connection to the specified remote host.
void Connect(System::ArrayPtr< System::SharedPtr< IPAddress > > ipAddresses, int32_t port)
Establishes a connection to the specified remote host.
System::SharedPtr< IAsyncResult > BeginConnect(System::ArrayPtr< System::SharedPtr< IPAddress > > addresses, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
void set_SendBufferSize(int32_t value)
Sets the size of the buffer that is used for sending data.
System::SharedPtr< Socket > get_Client()
Gets the socket.
void set_ReceiveBufferSize(int32_t value)
Sets the size of the buffer that is used for receiving data.
virtual ~TcpClient()
Destructs the current instance.
TcpClient()
Constructs a new instance.
System::SharedPtr< NetworkStream > GetStream()
Returns the stream that is used for sending and receiving data.
void set_SendTimeout(int32_t value)
Sets a value that indicates an amount of time after which data sending will time out.
int32_t get_SendTimeout()
Gets a value that indicates an amount of time after which data sending will time out.
void set_NoDelay(bool value)
Sets a value that indicates if the current instance is using the Nagle algorithm.
void set_ReceiveTimeout(int32_t value)
Sets a value that indicates an amount of time after which data receiving will time out.
TcpClient(System::SharedPtr< IPEndPoint > localEP)
Constructs a new instance.
void EndConnect(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous connect operation completes.
void Connect(System::SharedPtr< IPEndPoint > remoteEP)
Establishes a connection to the specified remote host.
void set_Client(System::SharedPtr< Socket > value)
Sets the socket.
bool get_Connected()
Returns a value that indicates if the socket is connected to the remote host.
bool get_ExclusiveAddressUse()
Gets a value that indicates if the current instance allows only one client to use a port.
bool get_NoDelay()
Gets a value that indicates if the current instance is using the Nagle algorithm.
System::SharedPtr< IAsyncResult > BeginConnect(System::SharedPtr< IPAddress > address, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
void Connect(System::SharedPtr< IPAddress > address, int32_t port)
Establishes a connection to the specified remote host.
void Close()
Closes the connection and disposes the current instance.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
AddressFamily
Enumerates the address families.
Definition: address_family.h:12
Definition: db_command.h:9
System::MulticastDelegate< void(SharedPtr< IAsyncResult >)> AsyncCallback
A delegate type that represents a method to be called when asynchronous operation completes.
Definition: async_callback.h:13