Show / Hide Table of Contents

Class NetworkUtils

Miscellaneuos utility methods for network related objects.

Inheritance
object
NetworkUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public static class NetworkUtils

Fields

NO_TIMEOUT

-1 is infinite for timeout.

Declaration
public static readonly long NO_TIMEOUT
Field Value
Type Description
long

Properties

PreferredAddressFamily

Gets or sets the preferred AddressFamily.

Declaration
public static AddressFamily PreferredAddressFamily { get; set; }
Property Value
Type Description
AddressFamily

Methods

Close(TcpClient)

Closes the given TcpClient object.

Declaration
public static bool Close(TcpClient client)
Parameters
Type Name Description
TcpClient client

The Socket object to close.

Returns
Type Description
bool

Returns true if the operation was successful; false otherwise.

GetAllAddresses(string)

Returns all available IP addresses for the specified host name.

Declaration
public static IPAddress[] GetAllAddresses(string hostName)
Parameters
Type Name Description
string hostName

The name of the host.

Returns
Type Description
IPAddress[]

An array of type IPAddress.

GetAllAddresses(string, long)

Returns all available IP addresses for the specified host name.

Declaration
public static IPAddress[] GetAllAddresses(string hostName, long cMillis)
Parameters
Type Name Description
string hostName

The name of the host.

long cMillis

The maximum amount of time to wait in getting the address

Returns
Type Description
IPAddress[]

An array of type IPAddress.

GetAllLocalAddresses()

Returns the list of all local addresses ofor all network interfaces on the local computer.

Declaration
public static IEnumerable<IPAddress> GetAllLocalAddresses()
Returns
Type Description
IEnumerable<IPAddress>

The list of all addresses for all network interfaces on the local computer.

GetHostAddress(string)

Returns first available IP address for the specified host name.

Declaration
public static IPAddress GetHostAddress(string hostName)
Parameters
Type Name Description
string hostName

The name of the host.

Returns
Type Description
IPAddress

A first available IP address for the specified host name.

GetHostAddress(string, long)

Returns first available IP address for the specified host name.

Declaration
public static IPAddress GetHostAddress(string hostName, long cMillis)
Parameters
Type Name Description
string hostName

The name of the host.

long cMillis

The maximum amount of time to wait in getting the address

Returns
Type Description
IPAddress

A first available IP address for the specified host name.

GetLocalHostAddress()

Returns the local host IP address.

Declaration
public static IPAddress GetLocalHostAddress()
Returns
Type Description
IPAddress

The local host IP address.

GetLocalHostAddress(long)

Returns the local host IP address.

Declaration
public static IPAddress GetLocalHostAddress(long cMillis)
Parameters
Type Name Description
long cMillis

The maximum amount of time to wait in getting the address

Returns
Type Description
IPAddress

The local host IP address.

IsAnyLocalAddress(IPAddress)

Determines if IPAddress is "Any" address.

Declaration
public static bool IsAnyLocalAddress(IPAddress address)
Parameters
Type Name Description
IPAddress address

An IPAddress.

Returns
Type Description
bool

true if address is equal to "Any" address; otherwise, false.

Remarks

The "Any" field is equivalent to 0.0.0.0 in dotted-quad notation.

IsLinkLocalAddress(IPAddress)

Determines if IPAddress is link local address.

Declaration
public static bool IsLinkLocalAddress(IPAddress address)
Parameters
Type Name Description
IPAddress address

An IPAddress.

Returns
Type Description
bool

true if address is link local address; otherwise, false.

IsLoopbackAddress(IPAddress)

Determines if IPAddress is loopback address.

Declaration
public static bool IsLoopbackAddress(IPAddress address)
Parameters
Type Name Description
IPAddress address

An IPAddress.

Returns
Type Description
bool

true if address is the loopback address; otherwise, false.

IsSiteLocalAddress(IPAddress)

Determines if IPAddress is site local address.

Declaration
public static bool IsSiteLocalAddress(IPAddress address)
Parameters
Type Name Description
IPAddress address

An IPAddress.

Returns
Type Description
bool

true if address is site local address; otherwise, false.

SetKeepAlive(TcpClient, bool)

Configure the KeepAlive option of the given Socket object.

Declaration
public static void SetKeepAlive(TcpClient client, bool keepAlive)
Parameters
Type Name Description
TcpClient client

Target Socket object.

bool keepAlive

Boolean parameter that represents the new KeepAlive value.

SetLingerTime(TcpClient, int)

Configure the linger time of the given Socket.

Declaration
public static void SetLingerTime(TcpClient client, int secs)
Parameters
Type Name Description
TcpClient client

Target Socket object.

int secs

The linger time in seconds (-1 to disable linger).

SetReceiveBufferSize(TcpClient, int)

Configure the ReceiveBuffer option of the given Socket object.

Declaration
public static void SetReceiveBufferSize(TcpClient client, int bufferSize)
Parameters
Type Name Description
TcpClient client

Target Socket object.

int bufferSize

Integer parameter that represents the new ReceiveBuffer value.

SetReuseAddress(TcpClient, bool)

Configure the ReuseAddress option of the given Socket object.

Declaration
public static void SetReuseAddress(TcpClient client, bool reuseAddress)
Parameters
Type Name Description
TcpClient client

Target Socket object.

bool reuseAddress

Boolean parameter that represents the new ReuseAddress value.

SetSendBufferSize(TcpClient, int)

Configure the SendBuffer option of the given Socket object.

Declaration
public static void SetSendBufferSize(TcpClient client, int bufferSize)
Parameters
Type Name Description
TcpClient client

Target Socket object.

int bufferSize

Integer parameter that represents the new SendBuffer value.

SetTcpNoDelay(TcpClient, bool)

Configure the NoDelay option of the given Socket object.

Declaration
public static void SetTcpNoDelay(TcpClient client, bool noDelay)
Parameters
Type Name Description
TcpClient client

Target Socket object.

bool noDelay

Boolean parameter that represents the new NoDelay value.

ToString(IPEndPoint)

Utility method that prints out an IPEndPoint in a user- friendly manner.

Declaration
public static string ToString(IPEndPoint addr)
Parameters
Type Name Description
IPEndPoint addr

IPEndPoint to print out.

Returns
Type Description
string

The value in format ADDRESS:PORT.

ToString(IPEndPoint, int)

Utility method that prints out an IPEndPoint with optional subport in a user-friendly manner.

Declaration
public static string ToString(IPEndPoint addr, int subport)
Parameters
Type Name Description
IPEndPoint addr

IPEndPoint to print out.

int subport

Subport, -1 if there is none.

Returns
Type Description
string

The value in format ADDRESS:BASEPORT.SUBPORT.

WriteSubport(Stream, int)

Write out the 8 byte multiplexed protocol header which consists of two 4-byte words: first is the protocol ID 0x05AC1E000, second is the subport number.

Declaration
public static void WriteSubport(Stream stream, int subport)
Parameters
Type Name Description
Stream stream

The output stream to write to.

int subport

The subport number.

In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.