CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
socket.h
1
2#pragma once
3
4#include <cstdint>
5#include <system/collections/ilist.h>
6#include <system/enum_helpers.h>
7#include <system/idisposable.h>
8#include <system/shared_ptr.h>
9#include <system/details/array_view.h>
10
11#include <net/end_point.h>
12#include <net/ip_address.h>
13#include <net/linger_option.h>
14#include <net/socket_type.h>
15#include <net/sockets/address_family.h>
16#include <net/sockets/io_control_code.h>
17#include <net/sockets/ip_packet_information.h>
18#include <net/sockets/protocol_type.h>
19#include <net/sockets/select_mode.h>
20#include <net/sockets/socket_error.h>
21#include <net/sockets/socket_flags.h>
22#include <net/sockets/socket_option_level.h>
23#include <net/sockets/socket_option_name.h>
24#include <net/sockets/socket_shutdown.h>
25#include <system/array_segment.h>
26
27
28namespace System { namespace Details {
29ASPOSECPP_3RD_PARTY_CLASS(io_service_impl);
30ASPOSECPP_3RD_PARTY_CLASS(socket_impl);
31}} // namespace System::Details
32
33namespace System { namespace Net { namespace Sockets {
34
36class ASPOSECPP_SHARED_CLASS Socket : public System::IDisposable
37{
38 friend class SocketAsyncResult;
39 friend class SocketCompletionHandler;
40
42 typedef Socket ThisType;
45
47 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
49 ASPOSECPP_SHARED_RTTI_INFO_DECL();
50
51public:
54 static ASPOSECPP_SHARED_API bool get_SupportsIPv4();
57 static ASPOSECPP_SHARED_API bool get_OSSupportsIPv4();
60 static ASPOSECPP_SHARED_API bool get_OSSupportsIPv6();
63 ASPOSECPP_SHARED_API int32_t get_Available();
72 ASPOSECPP_SHARED_API bool get_Blocking();
75 ASPOSECPP_SHARED_API void set_Blocking(bool value);
78 ASPOSECPP_SHARED_API bool get_Connected();
90 ASPOSECPP_SHARED_API bool get_IsBound();
93 ASPOSECPP_SHARED_API bool get_ExclusiveAddressUse();
96 ASPOSECPP_SHARED_API void set_ExclusiveAddressUse(bool value);
99 ASPOSECPP_SHARED_API int32_t get_ReceiveBufferSize();
102 ASPOSECPP_SHARED_API void set_ReceiveBufferSize(int32_t value);
105 ASPOSECPP_SHARED_API int32_t get_SendBufferSize();
108 ASPOSECPP_SHARED_API void set_SendBufferSize(int32_t value);
111 ASPOSECPP_SHARED_API int32_t get_ReceiveTimeout();
114 ASPOSECPP_SHARED_API void set_ReceiveTimeout(int32_t value);
117 ASPOSECPP_SHARED_API int32_t get_SendTimeout();
120 ASPOSECPP_SHARED_API void set_SendTimeout(int32_t value);
126 ASPOSECPP_SHARED_API void set_LingerState(System::SharedPtr<LingerOption> value);
129 ASPOSECPP_SHARED_API bool get_NoDelay();
132 ASPOSECPP_SHARED_API void set_NoDelay(bool value);
135 ASPOSECPP_SHARED_API int16_t get_Ttl();
138 ASPOSECPP_SHARED_API void set_Ttl(int16_t value);
141 ASPOSECPP_SHARED_API bool get_DontFragment();
144 ASPOSECPP_SHARED_API void set_DontFragment(bool value);
147 ASPOSECPP_SHARED_API bool get_MulticastLoopback();
150 ASPOSECPP_SHARED_API void set_MulticastLoopback(bool value);
153 ASPOSECPP_SHARED_API bool get_EnableBroadcast();
156 ASPOSECPP_SHARED_API void set_EnableBroadcast(bool value);
159 ASPOSECPP_SHARED_API bool get_DualMode();
162 ASPOSECPP_SHARED_API void set_DualMode(bool value);
163
167 ASPOSECPP_SHARED_API Socket(System::Net::Sockets::SocketType socketType,
173 ASPOSECPP_SHARED_API Socket(System::Net::Sockets::AddressFamily addressFamily,
176
185 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult> BeginSend(System::ArrayPtr<uint8_t> buffer, int32_t offset,
186 int32_t size, SocketFlags socketFlags,
187 AsyncCallback callback,
192 ASPOSECPP_SHARED_API int32_t EndSend(System::SharedPtr<IAsyncResult> asyncResult);
197 ASPOSECPP_SHARED_API int32_t EndSend(System::SharedPtr<IAsyncResult> asyncResult, SocketError& errorCode);
198
207 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult> BeginReceive(System::ArrayPtr<uint8_t> buffer, int32_t offset,
208 int32_t size, SocketFlags socketFlags,
209 AsyncCallback callback,
214 ASPOSECPP_SHARED_API int32_t EndReceive(System::SharedPtr<IAsyncResult> asyncResult);
219 ASPOSECPP_SHARED_API int32_t EndReceive(System::SharedPtr<IAsyncResult> asyncResult, SocketError& errorCode);
220
223 ASPOSECPP_SHARED_API void Bind(System::SharedPtr<EndPoint> localEP);
226 ASPOSECPP_SHARED_API void Connect(System::SharedPtr<EndPoint> remoteEP);
230 ASPOSECPP_SHARED_API void Connect(System::SharedPtr<IPAddress> address, int32_t port);
234 ASPOSECPP_SHARED_API void Connect(String host, int32_t port);
238 ASPOSECPP_SHARED_API void Connect(System::ArrayPtr<System::SharedPtr<IPAddress>> addresses, int32_t port);
239
245 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult>
253 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult>
254 BeginConnect(String host, int32_t port, AsyncCallback requestCallback, System::SharedPtr<Object> state);
262 int32_t port, AsyncCallback requestCallback,
270 ASPOSECPP_SHARED_API System::SharedPtr<IAsyncResult>
272 AsyncCallback requestCallback, System::SharedPtr<Object> state);
273
275 ASPOSECPP_SHARED_API void Close();
278 ASPOSECPP_SHARED_API void Close(int timeout);
279
282 ASPOSECPP_SHARED_API void EndConnect(System::SharedPtr<IAsyncResult> asyncResult);
283
286 ASPOSECPP_SHARED_API void Listen(int32_t backlog);
289 ASPOSECPP_SHARED_API System::SharedPtr<Socket> Accept();
295 ASPOSECPP_SHARED_API int32_t Send(System::ArrayPtr<uint8_t> buffer, int32_t size, SocketFlags socketFlags);
301 ASPOSECPP_SHARED_API int32_t Send(System::Details::ArrayView<uint8_t> buffer, int32_t size, SocketFlags socketFlags);
307 template<std::size_t N>
308 int32_t Send(System::Details::StackArray<uint8_t, N> &buffer, int32_t size, SocketFlags socketFlags)
309 {
310 return Send(static_cast<System::Details::ArrayView<uint8_t>>(buffer), size, socketFlags);
311 }
312
317 ASPOSECPP_SHARED_API int32_t Send(System::ArrayPtr<uint8_t> buffer, SocketFlags socketFlags);
322 ASPOSECPP_SHARED_API int32_t Send(System::Details::ArrayView<uint8_t> buffer, SocketFlags socketFlags);
327 template<std::size_t N>
328 int32_t Send(System::Details::StackArray<uint8_t, N> &buffer, SocketFlags socketFlags)
329 {
330 return Send(static_cast<System::Details::ArrayView<uint8_t>>(buffer), socketFlags);
331 }
332
336 ASPOSECPP_SHARED_API int32_t Send(System::ArrayPtr<uint8_t> buffer);
340 ASPOSECPP_SHARED_API int32_t Send(System::Details::ArrayView<uint8_t> buffer);
344 template<std::size_t N>
345 int32_t Send(System::Details::StackArray<uint8_t, N> &buffer)
346 {
347 return Send(static_cast<System::Details::ArrayView<uint8_t>>(buffer));
348 }
349
359 SocketFlags socketFlags);
366 SocketFlags socketFlags, SocketError& errorCode);
373 ASPOSECPP_SHARED_API int32_t Send(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
374 SocketFlags socketFlags);
381 ASPOSECPP_SHARED_API int32_t Send(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
382 SocketFlags socketFlags);
389 template<std::size_t N>
390 int32_t Send(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
391 {
392 return Send(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size, socketFlags);
393 }
394
402 ASPOSECPP_SHARED_API int32_t Send(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
403 SocketFlags socketFlags, SocketError& errorCode);
411 ASPOSECPP_SHARED_API int32_t Send(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
412 SocketFlags socketFlags, SocketError& errorCode);
420 template<std::size_t N>
421 int32_t Send(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
422 SocketFlags socketFlags, SocketError& errorCode)
423 {
424 return Send(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size, socketFlags, errorCode);
425 }
426
434 ASPOSECPP_SHARED_API int32_t SendTo(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
435 SocketFlags socketFlags, System::SharedPtr<EndPoint> remoteEP);
443 ASPOSECPP_SHARED_API int32_t SendTo(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
444 SocketFlags socketFlags, System::SharedPtr<EndPoint> remoteEP);
452 template<std::size_t N>
453 int32_t SendTo(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
454 SocketFlags socketFlags, System::SharedPtr<EndPoint> remoteEP)
455 {
456 return SendTo(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size, socketFlags, remoteEP);
457 }
458
465 ASPOSECPP_SHARED_API int32_t SendTo(System::ArrayPtr<uint8_t> buffer, int32_t size, SocketFlags socketFlags,
473 ASPOSECPP_SHARED_API int32_t SendTo(System::Details::ArrayView<uint8_t> buffer, int32_t size, SocketFlags socketFlags,
481 template<std::size_t N>
482 int32_t SendTo(System::Details::StackArray<uint8_t, N> &buffer, int32_t size, SocketFlags socketFlags,
484 {
485 return SendTo(static_cast<System::Details::ArrayView<uint8_t>>(buffer), size, socketFlags, remoteEP);
486 }
487
493 ASPOSECPP_SHARED_API int32_t SendTo(System::ArrayPtr<uint8_t> buffer, SocketFlags socketFlags,
500 ASPOSECPP_SHARED_API int32_t SendTo(System::Details::ArrayView<uint8_t> buffer, SocketFlags socketFlags,
507 template<std::size_t N>
508 int32_t SendTo(System::Details::StackArray<uint8_t, N> &buffer, SocketFlags socketFlags,
510 {
511 return SendTo(static_cast<System::Details::ArrayView<uint8_t>>(buffer), socketFlags, remoteEP);
512 }
517 ASPOSECPP_SHARED_API int32_t SendTo(System::ArrayPtr<uint8_t> buffer, System::SharedPtr<EndPoint> remoteEP);
522 ASPOSECPP_SHARED_API int32_t SendTo(System::Details::ArrayView<uint8_t> buffer, System::SharedPtr<EndPoint> remoteEP);
527 template<std::size_t N>
528 int32_t SendTo(System::Details::StackArray<uint8_t, N> &buffer, System::SharedPtr<EndPoint> remoteEP)
529 {
530 return SendTo(static_cast<System::Details::ArrayView<uint8_t>>(buffer), remoteEP);
531 }
537 ASPOSECPP_SHARED_API int32_t Receive(System::ArrayPtr<uint8_t> buffer, int32_t size, SocketFlags socketFlags);
543 ASPOSECPP_SHARED_API int32_t Receive(System::Details::ArrayView<uint8_t> buffer, int32_t size, SocketFlags socketFlags);
549 template<std::size_t N>
550 int32_t Receive(System::Details::StackArray<uint8_t, N> &buffer, int32_t size, SocketFlags socketFlags)
551 {
552 return Receive(static_cast<System::Details::ArrayView<uint8_t>>(buffer), size, socketFlags);
553 }
558 ASPOSECPP_SHARED_API int32_t Receive(System::ArrayPtr<uint8_t> buffer, SocketFlags socketFlags);
563 ASPOSECPP_SHARED_API int32_t Receive(System::Details::ArrayView<uint8_t> buffer, SocketFlags socketFlags);
568 template<std::size_t N>
569 int32_t Receive(System::Details::StackArray<uint8_t, N> &buffer, SocketFlags socketFlags)
570 {
571 return Receive(static_cast<System::Details::ArrayView<uint8_t>>(buffer), socketFlags);
572 }
576 ASPOSECPP_SHARED_API int32_t Receive(System::ArrayPtr<uint8_t> buffer);
580 ASPOSECPP_SHARED_API int32_t Receive(System::Details::ArrayView<uint8_t> buffer);
584 template<std::size_t N>
585 int32_t Receive(System::Details::StackArray<uint8_t, N> &buffer)
586 {
587 return Receive(static_cast<System::Details::ArrayView<uint8_t>>(buffer));
588 }
596 ASPOSECPP_SHARED_API int32_t Receive(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
597 SocketFlags socketFlags);
605 ASPOSECPP_SHARED_API int32_t Receive(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
606 SocketFlags socketFlags);
614 template<std::size_t N>
615 int32_t Receive(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
616 SocketFlags socketFlags)
617 {
618 return Receive(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size, socketFlags);
619 }
628 ASPOSECPP_SHARED_API int32_t Receive(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
629 SocketFlags socketFlags, SocketError& errorCode);
638 ASPOSECPP_SHARED_API int32_t Receive(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
639 SocketFlags socketFlags, SocketError& errorCode);
648 template<std::size_t N>
649 int32_t Receive(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
650 SocketFlags socketFlags, SocketError& errorCode)
651 {
652 return Receive(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size, socketFlags, errorCode);
653 }
663 SocketFlags socketFlags);
670 SocketFlags socketFlags, SocketError& errorCode);
680 ASPOSECPP_SHARED_API int32_t ReceiveMessageFrom(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
681 SocketFlags& socketFlags, System::SharedPtr<EndPoint>& remoteEP,
682 IPPacketInformation& ipPacketInformation);
692 ASPOSECPP_SHARED_API int32_t ReceiveMessageFrom(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
693 SocketFlags& socketFlags, System::SharedPtr<EndPoint>& remoteEP,
694 IPPacketInformation& ipPacketInformation);
704 template<std::size_t N>
705 int32_t ReceiveMessageFrom(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
706 SocketFlags& socketFlags, System::SharedPtr<EndPoint>& remoteEP,
707 IPPacketInformation& ipPacketInformation)
708 {
709 return ReceiveMessageFrom(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size,
710 socketFlags, remoteEP, ipPacketInformation);
711 }
720 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::ArrayPtr<uint8_t> buffer, int32_t offset, int32_t size,
721 SocketFlags socketFlags, System::SharedPtr<EndPoint>& remoteEP);
730 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::Details::ArrayView<uint8_t> buffer, int32_t offset, int32_t size,
731 SocketFlags socketFlags, System::SharedPtr<EndPoint>& remoteEP);
740 template<std::size_t N>
741 int32_t ReceiveFrom(System::Details::StackArray<uint8_t, N> &buffer, int32_t offset, int32_t size,
742 SocketFlags socketFlags, System::SharedPtr<EndPoint>& remoteEP)
743 {
744 return ReceiveFrom(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, size,
745 socketFlags, remoteEP);
746 }
754 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::ArrayPtr<uint8_t> buffer, int32_t size, SocketFlags socketFlags,
763 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::Details::ArrayView<uint8_t> buffer, int32_t size, SocketFlags socketFlags,
772 template<std::size_t N>
773 int32_t ReceiveFrom(System::Details::StackArray<uint8_t, N> &buffer, int32_t size, SocketFlags socketFlags,
775 {
776 return ReceiveFrom(static_cast<System::Details::ArrayView<uint8_t>>(buffer), size, socketFlags, remoteEP);
777 }
783 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::ArrayPtr<uint8_t> buffer, SocketFlags socketFlags,
790 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::Details::ArrayView<uint8_t> buffer, SocketFlags socketFlags,
797 template<std::size_t N>
800 {
801 return ReceiveFrom(static_cast<System::Details::ArrayView<uint8_t>>(buffer), socketFlags, remoteEP);
802 }
807 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::ArrayPtr<uint8_t> buffer, System::SharedPtr<EndPoint>& remoteEP);
812 ASPOSECPP_SHARED_API int32_t ReceiveFrom(System::Details::ArrayView<uint8_t> buffer, System::SharedPtr<EndPoint>& remoteEP);
817 template<std::size_t N>
818 int32_t ReceiveFrom(System::Details::StackArray<uint8_t, N> &buffer, System::SharedPtr<EndPoint>& remoteEP)
819 {
820 return ReceiveFrom(static_cast<System::Details::ArrayView<uint8_t>>(buffer), remoteEP);
821 }
827 ASPOSECPP_SHARED_API int32_t IOControl(int32_t ioControlCode, System::ArrayPtr<uint8_t> optionInValue,
828 System::ArrayPtr<uint8_t> optionOutValue);
834 ASPOSECPP_SHARED_API int32_t IOControl(IOControlCode ioControlCode, System::ArrayPtr<uint8_t> optionInValue,
835 System::ArrayPtr<uint8_t> optionOutValue);
840 ASPOSECPP_SHARED_API void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName,
841 int32_t optionValue);
846 ASPOSECPP_SHARED_API void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName,
847 System::ArrayPtr<uint8_t> optionValue);
852 ASPOSECPP_SHARED_API void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName,
853 bool optionValue);
858 ASPOSECPP_SHARED_API void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName,
859 System::SharedPtr<Object> optionValue);
865 SocketOptionName optionName);
870 ASPOSECPP_SHARED_API void GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName,
871 System::ArrayPtr<uint8_t> optionValue);
878 SocketOptionName optionName, int32_t optionLength);
883 ASPOSECPP_SHARED_API bool Poll(int32_t microSeconds, SelectMode mode);
886 ASPOSECPP_SHARED_API void Shutdown(SocketShutdown how);
888 ASPOSECPP_SHARED_API void Dispose() override;
889
891 virtual ASPOSECPP_SHARED_API ~Socket();
892
894 typedef std::shared_ptr<System::Details::socket_impl> ImplPtr;
897
900 ASPOSECPP_SHARED_API void set_ConnectionTimeout(int32_t value);
901
902
903private:
905 std::shared_ptr<System::Details::io_service_impl> io_service;
907 ImplPtr socket;
909 ProtocolType protocol;
913 System::SharedPtr<EndPoint> rightEndPoint;
915 int32_t connectionTimeout;
917 int32_t receiveTimeout;
919 int32_t sendTimeout;
920};
921}}} // namespace System::Net::Sockets
Represents a segment of the one-dimensional array. Objects of this class should only be allocated usi...
Definition: array_segment.h:63
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:19
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Represents information about the packet. Objects of this class should only be allocated using System:...
Definition: ip_packet_information.h:18
The Socket class implements the Berkeley sockets interface.
Definition: socket.h:37
int32_t SendTo(System::Details::StackArray< uint8_t, N > &buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
Definition: socket.h:508
int32_t Receive(System::Details::StackArray< uint8_t, N > &buffer, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
Definition: socket.h:550
System::Net::Sockets::SocketType get_SocketType()
Returns the socket type.
int32_t ReceiveMessageFrom(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags &socketFlags, System::SharedPtr< EndPoint > &remoteEP, IPPacketInformation &ipPacketInformation)
Receives data from the specified endpoint and writes it to the specified byte array.
Definition: socket.h:705
System::ArrayPtr< uint8_t > GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int32_t optionLength)
Returns the value that corresponds to the specified option name.
int32_t Send(System::ArrayPtr< uint8_t > buffer)
Sends the specified data to the socket.
void set_SendBufferSize(int32_t value)
Sets the send buffer size.
int32_t ReceiveFrom(System::Details::ArrayView< uint8_t > buffer, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
int32_t SendTo(System::Details::ArrayView< uint8_t > buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
int32_t get_SendTimeout()
Gets a period after which a 'Send' call will time out.
void set_SendTimeout(int32_t value)
Sets a period after which a 'Send' call will time out.
int32_t ReceiveFrom(System::ArrayPtr< uint8_t > buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
void EndConnect(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous connect operation completes.
void Connect(System::SharedPtr< IPAddress > address, int32_t port)
Establishes a connection to the specified remote endpoint.
int32_t Receive(System::Details::StackArray< uint8_t, N > &buffer)
Receives data from the socket and writes it to the specified byte array.
Definition: socket.h:585
void set_EnableBroadcast(bool value)
Sets a value that indicates if the socket allows broadcast packets.
void Close(int timeout)
Closes the socket connection with the specified timeout to allow queued data to be sent.
bool get_DualMode()
Gets a value indicates if the socket is in the dual-mode.
void set_MulticastLoopback(bool value)
Sets a value that indicates if the socket receives outgoing multicast packets.
int32_t Send(System::Details::ArrayView< uint8_t > buffer, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
int32_t Receive(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
int32_t ReceiveFrom(System::Details::ArrayView< uint8_t > buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
int32_t SendTo(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
bool get_ExclusiveAddressUse()
Gets a value that indicates if only one process can bind the socket to a port.
static bool get_OSSupportsIPv4()
Returns a value that indicates if the operating system and network adaptors support IPv4.
int32_t Receive(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Receives data from the socket and writes it to the specified byte array.
int32_t Send(System::Details::ArrayView< uint8_t > buffer)
Sends the specified data to the socket.
int32_t SendTo(System::Details::StackArray< uint8_t, N > &buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
Definition: socket.h:482
void set_NoDelay(bool value)
Sets a value that indicates if the socket is using the Nagle algorithm.
int32_t Send(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, System::SharedPtr< Object > optionValue)
Sets the specified socket option to the specified value.
int32_t Send(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers, SocketFlags socketFlags, SocketError &errorCode)
Sends the specified data to the socket.
System::SharedPtr< IAsyncResult > BeginSend(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, AsyncCallback callback, System::SharedPtr< Object > state)
Initiates an asynchronous send operation.
int32_t Send(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
Definition: socket.h:390
void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue)
Sets the specified socket option to the specified value.
void set_ReceiveBufferSize(int32_t value)
Sets the receive buffer size.
bool get_EnableBroadcast()
Gets a value that indicates if the socket allows broadcast packets.
int32_t SendTo(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
Definition: socket.h:453
static bool get_SupportsIPv4()
Returns a value that indicates if the current host supports IPv4.
int32_t Receive(System::Details::StackArray< uint8_t, N > &buffer, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
Definition: socket.h:569
void set_DontFragment(bool value)
Sets a value that indicates if the socket allows IP datagrams to be fragmented.
int32_t SendTo(System::ArrayPtr< uint8_t > buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
int32_t get_ReceiveBufferSize()
Gets the receive buffer size.
int32_t Send(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Sends the specified data to the socket.
Definition: socket.h:421
System::SharedPtr< IAsyncResult > BeginConnect(System::ArrayPtr< System::SharedPtr< IPAddress > > addresses, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
System::SharedPtr< Socket > Accept()
Creates a new socket for the newly created connection.
void set_ExclusiveAddressUse(bool value)
Sets a value that indicates if only one process can bind the socket to a port.
virtual ~Socket()
Destructs the current instance.
int32_t ReceiveFrom(System::ArrayPtr< uint8_t > buffer, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
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.
System::Net::Sockets::AddressFamily get_AddressFamily()
Returns the address family.
bool get_Blocking()
Gets a value that indicates if the socket is in the blocking mode.
int32_t Send(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers, SocketFlags socketFlags)
Sends the specified data to the socket.
int32_t Receive(System::Details::ArrayView< uint8_t > buffer, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
int32_t get_SendBufferSize()
Gets the send buffer size.
int32_t Receive(System::ArrayPtr< uint8_t > buffer, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
int32_t ReceiveFrom(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
Definition: socket.h:741
int32_t ReceiveMessageFrom(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags &socketFlags, System::SharedPtr< EndPoint > &remoteEP, IPPacketInformation &ipPacketInformation)
Receives data from the specified endpoint and writes it to the specified byte array.
int32_t Send(System::Details::StackArray< uint8_t, N > &buffer, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
Definition: socket.h:308
int32_t Receive(System::ArrayPtr< uint8_t > buffer)
Receives data from the socket and writes it to the specified byte array.
static bool get_OSSupportsIPv6()
Returns a value that indicates if the operating system and network adaptors support IPv6.
System::SharedPtr< Object > GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName)
Returns the value that corresponds to the specified option name.
void set_DualMode(bool value)
Sets a value indicates if the socket is in the dual-mode.
int32_t Receive(System::ArrayPtr< uint8_t > buffer, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
void Listen(int32_t backlog)
Changes the socket state to 'listen'.
int32_t Send(System::Details::StackArray< uint8_t, N > &buffer)
Sends the specified data to the socket.
Definition: socket.h:345
int32_t Send(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers)
Sends the specified data to the socket.
int32_t SendTo(System::Details::ArrayView< uint8_t > buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
bool get_MulticastLoopback()
Gets a value that indicates if the socket receives outgoing multicast packets.
int32_t EndSend(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous send operation completes.
int32_t Receive(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
int32_t Receive(System::Details::ArrayView< uint8_t > buffer, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
int32_t Receive(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Receives data from the socket and writes it to the specified byte array.
int32_t Receive(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte array.
Definition: socket.h:615
ImplPtr GetImpl() const
Returns a pointer to implementation.
void Bind(System::SharedPtr< EndPoint > localEP)
Binds the socket with to the specified local endpoint.
int32_t ReceiveFrom(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
System::SharedPtr< EndPoint > get_RemoteEndPoint()
Returns the remote endpoint.
int32_t SendTo(System::ArrayPtr< uint8_t > buffer, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
int32_t Receive(System::Details::ArrayView< uint8_t > buffer)
Receives data from the socket and writes it to the specified byte array.
int32_t SendTo(System::Details::ArrayView< uint8_t > buffer, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
System::Net::Sockets::ProtocolType get_ProtocolType()
Returns the protocol type.
int32_t IOControl(int32_t ioControlCode, System::ArrayPtr< uint8_t > optionInValue, System::ArrayPtr< uint8_t > optionOutValue)
Sets low-level operating modes for the socket.
int32_t Receive(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers)
Receives data from the socket and writes it to the specified byte arrays.
int32_t ReceiveFrom(System::Details::StackArray< uint8_t, N > &buffer, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
Definition: socket.h:818
void Close()
Closes the socket connection.
void set_Ttl(int16_t value)
Sets the TTL value.
int32_t ReceiveFrom(System::ArrayPtr< uint8_t > buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
int32_t SendTo(System::ArrayPtr< uint8_t > buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
void Connect(String host, int32_t port)
Establishes a connection to the specified remote endpoint.
int32_t get_ReceiveTimeout()
Gets a period after which a 'Receive' call will time out.
System::SharedPtr< IAsyncResult > BeginConnect(System::SharedPtr< IPAddress > address, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
System::SharedPtr< IAsyncResult > BeginReceive(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, AsyncCallback callback, System::SharedPtr< Object > state)
Initiates an asynchronous write operation.
int32_t Send(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
int32_t Send(System::Details::StackArray< uint8_t, N > &buffer, SocketFlags socketFlags)
Sends the specified data to the socket.
Definition: socket.h:328
int32_t SendTo(System::Details::StackArray< uint8_t, N > &buffer, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
Definition: socket.h:528
int32_t get_Available()
Gets the number of bytes received from the network and available for reading.
int32_t ReceiveFrom(System::Details::StackArray< uint8_t, N > &buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
Definition: socket.h:773
int32_t Receive(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers, SocketFlags socketFlags, SocketError &errorCode)
Receives data from the socket and writes it to the specified byte arrays.
int32_t Receive(System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Receives data from the socket and writes it to the specified byte array.
Definition: socket.h:649
void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, System::ArrayPtr< uint8_t > optionValue)
Sets the specified socket option to the specified value.
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 GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, System::ArrayPtr< uint8_t > optionValue)
Gets the value that corresponds to the specified option name.
Socket(System::Net::Sockets::AddressFamily addressFamily, System::Net::Sockets::SocketType socketType, System::Net::Sockets::ProtocolType protocolType)
Constructs a new instance.
int32_t EndReceive(System::SharedPtr< IAsyncResult > asyncResult, SocketError &errorCode)
Waits until the specified asynchronous receive operation completes.
bool get_Connected()
Returns a value that indicates if the socket is connected to the remote host.
void Connect(System::SharedPtr< EndPoint > remoteEP)
Establishes a connection to the specified remote endpoint.
int32_t IOControl(IOControlCode ioControlCode, System::ArrayPtr< uint8_t > optionInValue, System::ArrayPtr< uint8_t > optionOutValue)
Sets low-level operating modes for the socket.
int32_t ReceiveFrom(System::Details::ArrayView< uint8_t > buffer, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
bool get_DontFragment()
Gets a value that indicates if the socket allows IP datagrams to be fragmented.
System::SharedPtr< IAsyncResult > BeginConnect(System::SharedPtr< EndPoint > remoteEP, AsyncCallback callback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
int32_t Send(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Sends the specified data to the socket.
bool get_IsBound()
Returns a value that indicates if the socket is bound to a specific local port.
int32_t ReceiveFrom(System::ArrayPtr< uint8_t > buffer, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
Definition: socket.h:798
int16_t get_Ttl()
Gets the TTL value.
int32_t Send(System::ArrayPtr< uint8_t > buffer, SocketFlags socketFlags)
Sends the specified data to the socket.
bool Poll(int32_t microSeconds, SelectMode mode)
Returns the status of the socket based on the specified polling mode.
int32_t ReceiveMessageFrom(System::Details::ArrayView< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags &socketFlags, System::SharedPtr< EndPoint > &remoteEP, IPPacketInformation &ipPacketInformation)
Receives data from the specified endpoint and writes it to the specified byte array.
int32_t Send(System::Details::ArrayView< uint8_t > buffer, SocketFlags socketFlags)
Sends the specified data to the socket.
int32_t Send(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, SocketError &errorCode)
Sends the specified data to the socket.
void set_Blocking(bool value)
Sets a value that indicates if the socket is in the blocking mode.
int32_t SendTo(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > remoteEP)
Sends the specified data to the specified endpoint.
int32_t ReceiveFrom(System::ArrayPtr< uint8_t > buffer, int32_t offset, int32_t size, SocketFlags socketFlags, System::SharedPtr< EndPoint > &remoteEP)
Receives data from the specified endpoint and writes it to the specified byte array.
void Dispose() override
Does nothing.
int32_t Send(System::ArrayPtr< uint8_t > buffer, int32_t size, SocketFlags socketFlags)
Sends the specified data to the socket.
System::SharedPtr< IAsyncResult > BeginConnect(String host, int32_t port, AsyncCallback requestCallback, System::SharedPtr< Object > state)
Initiates an asynchronous connect operation.
void set_ConnectionTimeout(int32_t value)
Sets the connection timeout.
int32_t EndSend(System::SharedPtr< IAsyncResult > asyncResult, SocketError &errorCode)
Waits until the specified asynchronous send operation completes.
void Connect(System::ArrayPtr< System::SharedPtr< IPAddress > > addresses, int32_t port)
Establishes a connection to the specified remote endpoint.
int32_t EndReceive(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous receive operation completes.
std::shared_ptr< System::Details::socket_impl > ImplPtr
The socket implementation.
Definition: socket.h:894
void Shutdown(SocketShutdown how)
Disables the send and receive operations of the socket.
bool get_NoDelay()
Gets a value that indicates if the socket is using the Nagle algorithm.
void set_ReceiveTimeout(int32_t value)
Sets a period after which a 'Receive' call will time out.
void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int32_t optionValue)
Sets the specified socket option to the specified value.
int32_t Receive(System::SharedPtr< Collections::Generic::IList< ArraySegment< uint8_t > > > buffers, SocketFlags socketFlags)
Receives data from the socket and writes it to the specified byte arrays.
Socket(System::Net::Sockets::SocketType socketType, System::Net::Sockets::ProtocolType protocolType)
Constructs a new instance.
System::SharedPtr< EndPoint > get_LocalEndPoint()
Returns the local endpoint.
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
SelectMode
Specifies the mode for polling the status of the socket.
Definition: select_mode.h:10
SocketShutdown
Defines constants used by the Socket.Shutdown method.
Definition: socket_shutdown.h:10
@ Receive
Disables the socket for receiving.
@ Send
Disables the socket for sending.
IOControlCode
Enumerates the IO control codes.
Definition: io_control_code.h:12
AddressFamily
Enumerates the address families.
Definition: address_family.h:12
SocketOptionLevel
Defines socket option levels for the 'Socket' class.
Definition: socket_option_level.h:12
SocketError
Enumerates the socket error types.
Definition: socket_error.h:13
ProtocolType
Enumerates the protocol types.
Definition: protocol_type.h:12
SocketType
Enumerates the socket types.
Definition: socket_type.h:12
SocketOptionName
Defines socket option names for the Socket class.
Definition: socket_option_name.h:12
SocketFlags
Provides constant values for the socket messages.
Definition: socket_flags.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