CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
tcp_listener.h
1
2#pragma once
3
4#include <system/shared_ptr.h>
5#include <system/object.h>
6
7#include <net/sockets/tcp_client.h>
8#include <net/sockets/socket.h>
9#include <net/ip_end_point.h>
10
11namespace System {
12namespace Net {
13namespace Sockets {
14
19class ASPOSECPP_SHARED_CLASS TcpListener : public System::Object
20{
22 typedef TcpListener ThisType;
25
27 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
29 ASPOSECPP_SHARED_RTTI_INFO_DECL();
30
31public:
34 ASPOSECPP_SHARED_API System::SharedPtr<Socket> get_Server();
40 ASPOSECPP_SHARED_API bool get_ExclusiveAddressUse();
43 ASPOSECPP_SHARED_API void set_ExclusiveAddressUse(bool value);
44
47 ASPOSECPP_SHARED_API TcpListener(System::SharedPtr<IPEndPoint> localEP);
51 ASPOSECPP_SHARED_API TcpListener(System::SharedPtr<IPAddress> localaddr, int32_t port);
54 ASPOSECPP_SHARED_API TcpListener(int32_t port);
55
59 static ASPOSECPP_SHARED_API System::SharedPtr<TcpListener> Create(int32_t port);
62 ASPOSECPP_SHARED_API void AllowNatTraversal(bool allowed);
64 ASPOSECPP_SHARED_API void Start();
67 ASPOSECPP_SHARED_API void Start(int32_t backlog);
69 ASPOSECPP_SHARED_API void Stop();
72 ASPOSECPP_SHARED_API bool Pending();
96
97protected:
100 ASPOSECPP_SHARED_API bool get_Active();
101
102private:
104 System::SharedPtr<IPEndPoint> m_ServerSocketEP;
106 System::SharedPtr<Socket> m_ServerSocket;
108 bool m_Active;
110 bool m_ExclusiveAddressUse;
111};
112} // namespace Sockets
113} // namespace Net
114} // namespace System
Represents a listener for the TCP network services. Objects of this class should only be allocated us...
Definition: tcp_listener.h:20
System::SharedPtr< Socket > EndAcceptSocket(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous accept operation completes.
TcpListener(System::SharedPtr< IPEndPoint > localEP)
Constructs a new instance.
bool get_ExclusiveAddressUse()
Gets a value that indicates if the current instance allows only one client to use a port.
System::SharedPtr< IAsyncResult > BeginAcceptTcpClient(AsyncCallback callback, System::SharedPtr< Object > state)
Initiates an asynchronous accept operation.
void Start(int32_t backlog)
Starts listening for the incoming connections.
void Start()
Starts listening for the incoming connections.
System::SharedPtr< TcpClient > AcceptTcpClient()
Accepts the pending connection request and returns the TcpClient-class instance that is used for send...
TcpListener(int32_t port)
Constructs a new instance.
System::SharedPtr< Socket > get_Server()
Returns the underlying network socket.
void Stop()
Stops listening for the incoming connections.
static System::SharedPtr< TcpListener > Create(int32_t port)
Creates a new instance using the specified port number.
void AllowNatTraversal(bool allowed)
Enables or disables the NAT traversal.
void set_ExclusiveAddressUse(bool value)
Sets a value that indicates if the current instance allows only one client to use a port.
System::SharedPtr< Socket > AcceptSocket()
Accepts the pending connection request and returns the socket that is used to send and receive data.
TcpListener(System::SharedPtr< IPAddress > localaddr, int32_t port)
Constructs a new instance.
System::SharedPtr< TcpClient > EndAcceptTcpClient(System::SharedPtr< IAsyncResult > asyncResult)
Waits until the specified asynchronous accept operation completes.
bool get_Active()
Returns a value that indicates if the current instance is actively listening for the client connectio...
System::SharedPtr< EndPoint > get_LocalEndpoint()
Returns the underlying endpoint.
bool Pending()
Returns a value that indicates if there are pending connection requests.
System::SharedPtr< IAsyncResult > BeginAcceptSocket(AsyncCallback callback, System::SharedPtr< Object > state)
Initiates an asynchronous accept operation.
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
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