NetworkIpInterface Class Reference

#include <network_ip.h>

详细描述

Static interface to access network functionality.

公共成员函数

  MAXON_OBSERVABLE_STATIC (void, ObservableNetworkInterfaceChanged,(), ObservableCombinerRunAllComponent)

静态公共成员函数

static MAXON_METHOD Result < NetworkConnectionRef >  OpenListener (const NetworkIpAddrPort &address, const ThreadRef &thread, TimeValue connectionTimeout, Bool useNagleAlgorithm)
static MAXON_METHOD Result < NetworkConnectionRef >  OpenListener (const String &address, const ThreadRef &thread, TimeValue connectionTimeout, Bool useNagleAlgorithm)
static MAXON_METHOD Result < NetworkConnectionRef >  OpenWaitForIncoming (const NetworkConnectionRef &listener, const ThreadRef &connection, TimeValue connectionTimeout, Bool fullDuplex)
static MAXON_METHOD Result < NetworkConnectionRef >  OpenOutgoing (const NetworkIpAddrPort &address, const ThreadRef &thread, TimeValue connectTimeout, TimeValue sessionTimeout, Bool useNagleAlgorithm, Bool fullDuplex)
static MAXON_METHOD Result < NetworkConnectionRef >  OpenOutgoing (const String &address, const ThreadRef &thread, TimeValue connectTimeout, TimeValue sessionTimeout, Bool useNagleAlgorithm, Bool fullDuplex)
static MAXON_METHOD Result < String GetHostname ()
static MAXON_METHOD Result < String GetHostname (const NetworkIpAddr &ipAddr, Bool useShortHostname=false)
static MAXON_METHOD ReturnResolveError   ResolveHostname (const String &address, PROTOCOL ptype, BaseArray < NetworkIpAddr > &arr, Bool firstMatch=true, Bool forceResolve=false)
static MAXON_METHOD Result < void >  SplitAddress (const String &address, String *scheme, String *host, Int32 *port)
static MAXON_METHOD Result < Bool SocketIOWait ( SOCKET socket, SOCKETMODE 模式, TimeValue timeoutMode, const ThreadRef &bt)
static MAXON_METHOD Result < NetworkIpAddr GetIpAddress (const String &address, Bool resolve=true, Bool forceResolve=false)
static MAXON_METHOD Result < NetworkIpAddrPort GetIpAddressAndPort (const String &address, Bool resolve=true, Bool forceResolve=false)
static MAXON_METHOD Result < void >  WakeOnLan (const BaseArray < UChar > &macAddress, const NetworkIpAddr &broadcastAddress)
static MAXON_METHOD String   GetTimeString ()
static MAXON_METHOD NetworkIpAddr   GetBroadcastAddress (const NetworkIpAddr &ipAddress, const NetworkIpAddr &subnetMask)
static MAXON_METHOD Result < BaseArray < UChar > >  GetMacAddress ()
static MAXON_METHOD String   MacAddressToString (const BaseArray < UChar > &macAddress)
static MAXON_METHOD Result < Int GetAdapterIndex (const String &adapterName)
static MAXON_METHOD Result < NetworkAdapter >  GetBestNetworkAdapter ( PROTOCOL protocol= PROTOCOL::IPV4 )
static MAXON_METHOD Result < BaseArray < NetworkAdapter > >  GetAllNetworkAdapters ()
static MAXON_METHOD Result < Int GetAdapterIndex (const NetworkIpAddr &address)

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( NetworkIpInterface , MAXON_REFERENCE_NORMAL , "net.maxon.interface.networkip")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( NetworkIpInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.interface.networkip"   
)
private

◆  OpenListener() [1/2]

static MAXON_METHOD Result <NetworkConnectionRef> OpenListener ( const NetworkIpAddrPort address ,
const ThreadRef thread ,
TimeValue   connectionTimeout ,
Bool   useNagleAlgorithm  
)
static

Creates an NetworkIpConnection listener. When the listener is created use OpenWaitForIncoming() to wait for incoming connections. Shutdown the listener with CloseConnection() . When the machine / device goes into the sleep mode and wakes up again, the listener is still active and ready to accept connections.

参数
[in] address Addresses where the socket is binded to. Pass en empty instance to listen on all adapters.
[in] thread Thread object where this function is called from. Used to interrupt a connection on TestBreak()
[in] connectionTimeout Timeout of the listener object. Use SOCKETTIMEOUT_INDEFINITELY to disable timeout. Use NETWORK_DEFAULT_CONNECTION_TIMEOUT if you want to have the recommended default values.
[in] useNagleAlgorithm Set to true to use the Nagle algorithm, otherwise false.
返回
Listener object.

◆  OpenListener() [2/2]

static MAXON_METHOD Result <NetworkConnectionRef> OpenListener ( const String address ,
const ThreadRef thread ,
TimeValue   connectionTimeout ,
Bool   useNagleAlgorithm  
)
static

Creates an NetworkIpConnection listener. When the listener is created use OpenWaitForIncoming() to wait for incoming connections. Shutdown the listener with CloseConnection() . When the machine / device goes into the sleep mode and wakes up again, the listener is still active and ready to accept connections.

参数
[in] address Address as string where the socket is binded to (e.g. "192.168.10.200:1234"). Pass en empty string or "0"
[in] thread Thread object where this function is called from. Used to interrupt a connection on TestBreak()
[in] connectionTimeout Timeout of the listener object. Use SOCKETTIMEOUT_INDEFINITELY to disable timeout. Use NETWORK_DEFAULT_CONNECTION_TIMEOUT if you want to have the recommended default values.
[in] useNagleAlgorithm Set to true to use the Nagle algorithm, otherwise false.
返回
Listener object.

◆  OpenWaitForIncoming()

static MAXON_METHOD Result <NetworkConnectionRef> OpenWaitForIncoming ( const NetworkConnectionRef &  listener ,
const ThreadRef connection ,
TimeValue   connectionTimeout ,
Bool   fullDuplex  
)
static

Waits for an incoming connection and blocks until a connection was established.

参数
[in] listener Listener object from OpenListener() .
[in] connection Thread object where this function is called from. Used to interrupt this call on TestBreak().
[in] connectionTimeout Timeout in seconds for further operations like send or receive. Use SOCKETTIMEOUT_INDEFINITELY to disable timeout. Use NETWORK_DEFAULT_CONNECTION_TIMEOUT if you want to have the recommended default values.
[in] fullDuplex Set the connection to full duplex mode which means that parallel read and write is allowed.
返回
Incoming connection object or nullptr when an error occured or TestBreak() was called. In this case the content of ferr will be 0.

◆  OpenOutgoing() [1/2]

static MAXON_METHOD Result <NetworkConnectionRef> OpenOutgoing ( const NetworkIpAddrPort address ,
const ThreadRef thread ,
TimeValue   connectTimeout ,
TimeValue   sessionTimeout ,
Bool   useNagleAlgorithm ,
Bool   fullDuplex  
)
static

Opens a connection. Supports IPv4 and IPv6.

参数
[in] address Pass a host name to connect to. Can be an IPv4, IPv6 address or a host name.
[in] thread TODO: (Seb) ?
[in] connectTimeout Timeout in seconds for the initial connection. Use NETWORK_DEFAULT_INITIAL_TIMEOUT if you want to have the recommended default values.
[in] sessionTimeout Timeout in seconds for further operations like send or receive. Use SOCKETTIMEOUT_INDEFINITELY to disable timeout. Use NETWORK_DEFAULT_CONNECTION_TIMEOUT if you want to have the recommended default values.
[in] useNagleAlgorithm Pass true to set the TCP/IP flag for TCP_NODELAY. For more information see: http://msdn.microsoft.com/en-us/library/ms817942.aspx .
[in] fullDuplex Set the connection to full duplex mode which means that parallel read and write is allowed.
返回
Connection object for the outgoing connection. Must be freed with CloseConnection.

◆  OpenOutgoing() [2/2]

static MAXON_METHOD Result <NetworkConnectionRef> OpenOutgoing ( const String address ,
const ThreadRef thread ,
TimeValue   connectTimeout ,
TimeValue   sessionTimeout ,
Bool   useNagleAlgorithm ,
Bool   fullDuplex  
)
static

◆  GetHostname() [1/2]

static MAXON_METHOD Result < String > GetHostname ( )
static

Returns the host name of the local machine.

◆  GetHostname() [2/2]

static MAXON_METHOD Result < String > GetHostname ( const NetworkIpAddr ipAddr ,
Bool   useShortHostname = false  
)
static

Returns the host name of given ip address.

◆  MAXON_OBSERVABLE_STATIC()

MAXON_OBSERVABLE_STATIC ( void  ,
ObservableNetworkInterfaceChanged  ,
()  ,
ObservableCombinerRunAllComponent   
)

◆  ResolveHostname()

static MAXON_METHOD ReturnResolveError ResolveHostname ( const String address ,
PROTOCOL   ptype ,
BaseArray < NetworkIpAddr > &  arr ,
Bool   firstMatch = true ,
Bool   forceResolve = false  
)
static

Resolves a host name. If the address object can be an ip address object, you should use GetIpAddress(address, a, true) instead.

参数
[in] address Host name to resolve.
[in] ptype Pass PROTOCOL::IPV4 if the result should just contain IPv4 address, same for PROTOCOL::IPV6 with IPv6 address and PROTOCOL::ALL for all addresses.
[out] arr Contains the addresses of the host name when the function succeeded.
[in] firstMatch Address array has a maximum size of 1 element.
[in] forceResolve Set to true to resolve the address via the DNS system.
返回
返回 RESOLVERESULT::OK on success, otherwise the resolve operation failed.

◆  SplitAddress()

static MAXON_METHOD Result <void> SplitAddress ( const String address ,
String scheme ,
String host ,
Int32 port  
)
static

Splits a passed address in its elements.

◆  SocketIOWait()

static MAXON_METHOD Result < Bool > SocketIOWait ( SOCKET   socket ,
SOCKETMODE   mode ,
TimeValue   timeoutMode ,
const ThreadRef bt  
)
static

◆  GetIpAddress()

static MAXON_METHOD Result < NetworkIpAddr > GetIpAddress ( const String address ,
Bool   resolve = true ,
Bool   forceResolve = false  
)
static

Converts a host name, IPv4 or IPv6 address into an ip address object. A port value in the address will be ignored. When the resolve option is enabled, the call blocks and waits for the DNS system when the address is a host name. E.g: address: Sebastians-Macbook-Pro.local (DNS system used, call blocks) address: 192.168.10.1 (no DNS system used, call does not block)

参数
[in] address IP address or host name. If the string is a host name, resolve must be set to true otherwise the function fails.
[in] resolve Set to true to resolve the address via the DNS system.
[in] forceResolve TODO: (Seb) ?
返回
Assigned ip address object.

◆  GetIpAddressAndPort()

static MAXON_METHOD Result < NetworkIpAddrPort > GetIpAddressAndPort ( const String address ,
Bool   resolve = true ,
Bool   forceResolve = false  
)
static

Converts a host name, IPv4 or IPv6` address into an ip address object. The address can have a port value. When the resolve option is enabled, the call blocks and waits for the DNS system when the address is a host name. E.g: address: Sebastians-Macbook-Pro.local:1234 (DNS system used, call blocks) address: 192.168.10.1:1234 (no DNS system used, call does not block)

参数
[in] address IP address or host name. If the string is a host name, resolve must be set to true otherwise the function fails.
[in] resolve Set to true to resolve the address via the DNS system.
[in] forceResolve TODO: (Seb) ?
返回
Assigned ip address object.

◆  WakeOnLan()

static MAXON_METHOD Result <void> WakeOnLan ( const BaseArray < UChar > &  macAddress ,
const NetworkIpAddr broadcastAddress  
)
static

Wakes a computer up by WOL (Wake-On-LAN). Currently only IPv4 is supported. To get WOL to work, a broadcast message on port '9' will be sent.

参数
[in] macAddress Mac-Address of the machine which will be woken up.
[in] broadcastAddress Broadcast address where the message should be send to.
返回
True on success if the message was sent, otherwise false.

◆  GetTimeString()

static MAXON_METHOD String GetTimeString ( )
static

Create a human-readable time string.

返回
Time string.

◆  GetBroadcastAddress()

static MAXON_METHOD NetworkIpAddr GetBroadcastAddress ( const NetworkIpAddr ipAddress ,
const NetworkIpAddr subnetMask  
)
static

Convert a IPv4 broadcast address by a given ip and subnet address.

参数
[in] ipAddress IP address.
[in] subnetMask Subnet address.
返回
Broadcast address.

◆  GetMacAddress()

static MAXON_METHOD Result < BaseArray < UChar > > GetMacAddress ( )
static

Get the mac address of the machine. When this function returns false an error occurred, but then macAddress is filled at least with a random-generated macAddress. The random-generated mac address will be changed after a restart of the host application.

返回
BaseArray with the mac address.

◆  MacAddressToString()

static MAXON_METHOD String MacAddressToString ( const BaseArray < UChar > &  macAddress )
static

Prints a mac address to the debug console. The output is visible in debug builds or in a release build when the debug console with diagnostic output is activated.

参数
[in] macAddress The mac address.

◆  GetAdapterIndex() [1/2]

static MAXON_METHOD Result < Int > GetAdapterIndex ( const String adapterName )
static

Returns the adapter index. The interface name "all" returns 0.

参数
[in] adapterName The name.
返回
The index.

◆  GetBestNetworkAdapter()

static MAXON_METHOD Result <NetworkAdapter> GetBestNetworkAdapter ( PROTOCOL   protocol = PROTOCOL::IPV4 )
static

Returns the best network adapter to the specified protocol.

参数
[in] protocol Specified protocol.
返回
The found network adapter.

◆  GetAllNetworkAdapters()

static MAXON_METHOD Result < BaseArray <NetworkAdapter> > GetAllNetworkAdapters ( )
static

Returns all current active network adapter objects.

返回
Array with all network adapters.

◆  GetAdapterIndex() [2/2]

static MAXON_METHOD Result < Int > GetAdapterIndex ( const NetworkIpAddr address )
static

Returns the interface index of the network adapter that is in the same network as the given address. It's not required that the address is assigned to the adapter itself. If no match was found, -1 is returned.

返回
Interface index of matching network adapter.