Network
open class Network : Parcelable
Identifies a Network. This is supplied to applications via ConnectivityManager.NetworkCallback in response to the active ConnectivityManager#requestNetwork or passive ConnectivityManager#registerNetworkCallback calls. It is used to direct traffic to the given Network, either on a Socket basis through a targeted SocketFactory or process-wide via ConnectivityManager#bindProcessToNetwork.
Summary
| Inherited constants |
From class Parcelable
Int |
CONTENTS_FILE_DESCRIPTOR
Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.
|
Int |
PARCELABLE_WRITE_RETURN_VALUE
Flag for use with writeToParcel: the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". Some implementations may want to release resources at this point.
|
|
| Public methods |
| open Unit |
Binds the specified DatagramSocket to this Network.
|
| open Unit |
Binds the specified Socket to this Network.
|
| open Unit |
Binds the specified FileDescriptor to this Network.
|
| open Int |
|
| open Boolean |
|
| open static Network! |
Returns a Network object given a handle returned from getNetworkHandle.
|
| open Array<InetAddress!>! |
Operates the same as InetAddress.getAllByName except that host resolution is done on this network.
|
| open InetAddress! |
Operates the same as InetAddress.getByName except that host resolution is done on this network.
|
| open Long |
Returns a handle representing this Network, for use with the NDK API.
|
| open SocketFactory! |
Returns a SocketFactory bound to this network.
|
| open Int |
|
| open URLConnection! |
Opens the specified URL on this Network, such that all traffic will be sent on this Network.
|
| open URLConnection! |
Opens the specified URL on this Network, such that all traffic will be sent on this Network.
|
| open String |
|
| open Unit |
|
Public methods
bindSocket
open fun bindSocket(socket: Socket!): Unit
Binds the specified Socket to this Network. All data traffic on the socket will be sent on this Network, irrespective of any process-wide network binding set by ConnectivityManager#bindProcessToNetwork. The socket must not be connected.
describeContents
open fun describeContents(): Int
equals
open fun equals(other: Any?): Boolean
| Parameters |
obj |
the reference object with which to compare. |
| Return |
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getAllByName
open fun getAllByName(host: String!): Array<InetAddress!>!
Operates the same as InetAddress.getAllByName except that host resolution is done on this network.
| Parameters |
host |
String!: the hostname or literal IP string to be resolved. |
| Return |
Array<InetAddress!>! |
the array of addresses associated with the specified host. |
| Exceptions |
java.net.UnknownHostException |
if the address lookup fails. |
getByName
open fun getByName(host: String!): InetAddress!
Operates the same as InetAddress.getByName except that host resolution is done on this network.
| Parameters |
host |
String!: the hostname to be resolved to an address or null. |
| Return |
InetAddress! |
the InetAddress instance representing the host. |
| Exceptions |
java.net.UnknownHostException |
if the address lookup fails. |
getNetworkHandle
open fun getNetworkHandle(): Long
Returns a handle representing this Network, for use with the NDK API.
getSocketFactory
open fun getSocketFactory(): SocketFactory!
Returns a SocketFactory bound to this network. Any Socket created by this factory will have its traffic sent over this Network. Note that if this Network ever disconnects, this factory and any Socket it produced in the past or future will cease to work.
hashCode
open fun hashCode(): Int
| Return |
Int |
a hash code value for this object. |
openConnection
open fun openConnection(url: URL!): URLConnection!
Opens the specified URL on this Network, such that all traffic will be sent on this Network. The URL protocol must be HTTP or HTTPS.
| Return |
URLConnection! |
a URLConnection to the resource referred to by this URL. |
| Exceptions |
java.net.MalformedURLException |
if the URL protocol is not HTTP or HTTPS. |
java.io.IOException |
if an error occurs while opening the connection. |
openConnection
open fun openConnection(
url: URL!,
proxy: Proxy!
): URLConnection!
Opens the specified URL on this Network, such that all traffic will be sent on this Network. The URL protocol must be HTTP or HTTPS.
| Parameters |
proxy |
Proxy!: the proxy through which the connection will be established. |
| Return |
URLConnection! |
a URLConnection to the resource referred to by this URL. |
| Exceptions |
java.net.MalformedURLException |
if the URL protocol is not HTTP or HTTPS. |
java.lang.IllegalArgumentException |
if the argument proxy is null. |
java.io.IOException |
if an error occurs while opening the connection. |
toString
open fun toString(): String
| Return |
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
dest: Parcel!,
flags: Int
): Unit
Properties