Stay organized with collections
Save and categorize content based on your preferences.
IpSecManager.UdpEncapsulationSocket
public
static
final
class
IpSecManager.UdpEncapsulationSocket
extends Object
implements
AutoCloseable
This class provides access to a UDP encapsulation Socket.
UdpEncapsulationSocket
wraps a system-provided datagram socket intended for IKEv2
signalling and UDP encapsulated IPsec traffic. Instances can be obtained by calling IpSecManager.openUdpEncapsulationSocket()
. The provided socket cannot be re-bound by the
caller. The caller should not close the FileDescriptor
returned by getFileDescriptor()
, but should use close()
instead.
Allowing the user to close or unbind a UDP encapsulation socket could impact the traffic
of the next user who binds to that port. To prevent this scenario, these sockets are held
open by the system so that they may only be closed by calling close()
or when the user
process exits.
Summary
Protected methods |
void
|
finalize()
Check that the socket was closed properly.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
|
Public methods
close
public void close ()
Close this socket.
This closes the wrapped socket. Open encapsulation sockets count against a user's
resource limits, and forgetting to close them eventually will result in ResourceUnavailableException
being thrown.
getFileDescriptor
public FileDescriptor getFileDescriptor ()
Get the encapsulation socket's file descriptor.
getPort
public int getPort ()
Get the bound port of the wrapped socket.
toString
public String toString ()
Returns a string representation of the object.
Returns |
String |
a string representation of the object. |
Protected methods
finalize
protected void finalize ()
Check that the socket was closed properly.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# IpSecManager.UdpEncapsulationSocket\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Protected Methods](#promethods) \\| [Inherited Methods](#inhmethods) \n\nIpSecManager.UdpEncapsulationSocket\n===================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/net/IpSecManager.UdpEncapsulationSocket \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\nfinal\n\nclass\nIpSecManager.UdpEncapsulationSocket\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\nimplements\n\n`[AutoCloseable](/reference/java/lang/AutoCloseable)`\n\n\n`\n\n|---|-------------------------------------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | android.net.IpSecManager.UdpEncapsulationSocket |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis class provides access to a UDP encapsulation Socket.\n\n`UdpEncapsulationSocket` wraps a system-provided datagram socket intended for IKEv2\nsignalling and UDP encapsulated IPsec traffic. Instances can be obtained by calling [IpSecManager.openUdpEncapsulationSocket()](/reference/android/net/IpSecManager#openUdpEncapsulationSocket()). The provided socket cannot be re-bound by the\ncaller. The caller should not close the `FileDescriptor` returned by [getFileDescriptor()](/reference/android/net/IpSecManager.UdpEncapsulationSocket#getFileDescriptor()), but should use [close()](/reference/android/net/IpSecManager.UdpEncapsulationSocket#close()) instead.\n\nAllowing the user to close or unbind a UDP encapsulation socket could impact the traffic\nof the next user who binds to that port. To prevent this scenario, these sockets are held\nopen by the system so that they may only be closed by calling [close()](/reference/android/net/IpSecManager.UdpEncapsulationSocket#close()) or when the user\nprocess exits.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[close](/reference/android/net/IpSecManager.UdpEncapsulationSocket#close())`() ` Close this socket. |\n| ` `[FileDescriptor](/reference/java/io/FileDescriptor) | ` `[getFileDescriptor](/reference/android/net/IpSecManager.UdpEncapsulationSocket#getFileDescriptor())`() ` Get the encapsulation socket's file descriptor. |\n| ` int` | ` `[getPort](/reference/android/net/IpSecManager.UdpEncapsulationSocket#getPort())`() ` Get the bound port of the wrapped socket. |\n| ` `[String](/reference/java/lang/String) | ` `[toString](/reference/android/net/IpSecManager.UdpEncapsulationSocket#toString())`() ` Returns a string representation of the object. |\n\n| ### Protected methods ||\n|---------|--------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[finalize](/reference/android/net/IpSecManager.UdpEncapsulationSocket#finalize())`() ` Check that the socket was closed properly. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n| From interface ` `[java.lang.AutoCloseable](/reference/java/lang/AutoCloseable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||\n\nPublic methods\n--------------\n\n### close\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void close ()\n```\n\nClose this socket.\n\nThis closes the wrapped socket. Open encapsulation sockets count against a user's\nresource limits, and forgetting to close them eventually will result in [ResourceUnavailableException](/reference/android/net/IpSecManager.ResourceUnavailableException) being thrown.\n\n\u003cbr /\u003e\n\n| Throws ||\n|-----------------------------------------------|---|\n| [IOException](/reference/java/io/IOException) | |\n\n### getFileDescriptor\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic FileDescriptor getFileDescriptor ()\n```\n\nGet the encapsulation socket's file descriptor.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------------------------|--------|\n| [FileDescriptor](/reference/java/io/FileDescriptor) | \u003cbr /\u003e |\n\n### getPort\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic int getPort ()\n```\n\nGet the bound port of the wrapped socket.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### toString\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic String toString ()\n```\n\nReturns a string representation of the object.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|-----------------------------------------------|\n| [String](/reference/java/lang/String) | a string representation of the object. \u003cbr /\u003e |\n\nProtected methods\n-----------------\n\n### finalize\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\nprotected void finalize ()\n```\n\nCheck that the socket was closed properly.\n\n\u003cbr /\u003e\n\n| Throws ||\n|---------------------------------------------|---|\n| [Throwable](/reference/java/lang/Throwable) | |"]]