Stay organized with collections
Save and categorize content based on your preferences.
UdpEncapsulationSocket
class UdpEncapsulationSocket : 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 android.net.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
Public methods |
Unit |
Close this socket.
|
FileDescriptor! |
Get the encapsulation socket's file descriptor.
|
Int |
Get the bound port of the wrapped socket.
|
String |
|
Protected methods |
Unit |
Check that the socket was closed properly.
|
Public methods
close
fun close(): Unit
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.
Exceptions |
java.lang.Exception |
if this resource cannot be closed |
getFileDescriptor
fun getFileDescriptor(): FileDescriptor!
Get the encapsulation socket's file descriptor.
getPort
fun getPort(): Int
Get the bound port of the wrapped socket.
toString
fun toString(): String
Return |
String |
a string representation of the object. |
Protected methods
finalize
protected fun finalize(): Unit
Check that the socket was closed properly.
Exceptions |
java.lang.Throwable |
the Exception raised by this method |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# IpSecManager.UdpEncapsulationSocket\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nUdpEncapsulationSocket\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/IpSecManager.UdpEncapsulationSocket \"View this page in Java\") \n\n```\nclass UdpEncapsulationSocket : AutoCloseable\n```\n\n|---|------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.IpSecManager.UdpEncapsulationSocket](#) |\n\nThis class provides access to a UDP encapsulation Socket.\n\n`UdpEncapsulationSocket` wraps a system-provided datagram socket intended for IKEv2 signalling and UDP encapsulated IPsec traffic. Instances can be obtained by calling android.net.IpSecManager#openUdpEncapsulationSocket. The provided socket cannot be re-bound by the caller. The caller should not close the `FileDescriptor` returned by [getFileDescriptor](#getFileDescriptor()), but should use [close](#close()) instead.\n\nAllowing 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](#close()) or when the user process exits.\n\nSummary\n-------\n\n| Public methods ||\n|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [close](#close())`()` Close this socket. |\n| [FileDescriptor](../../java/io/FileDescriptor.html#)! | [getFileDescriptor](#getFileDescriptor())`()` Get the encapsulation socket's file descriptor. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getPort](#getPort())`()` Get the bound port of the wrapped socket. |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n\n| Protected methods ||\n|------------------------------------------------------------------------------|------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finalize](#finalize())`()` Check that the socket was closed properly. |\n\nPublic methods\n--------------\n\n### close\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun close(): Unit\n```\n\nClose this socket.\n\nThis closes the wrapped socket. Open encapsulation sockets count against a user's resource limits, and forgetting to close them eventually will result in [ResourceUnavailableException](/reference/kotlin/android/net/IpSecManager.ResourceUnavailableException) being thrown.\n\n| Exceptions ||\n|-----------------------|-----------------------------------|\n| `java.lang.Exception` | if this resource cannot be closed |\n\n### getFileDescriptor\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getFileDescriptor(): FileDescriptor!\n```\n\nGet the encapsulation socket's file descriptor. \n\n### getPort\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getPort(): Int\n```\n\nGet the bound port of the wrapped socket. \n\n### toString\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |\n\nProtected methods\n-----------------\n\n### finalize\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected fun finalize(): Unit\n```\n\nCheck that the socket was closed properly.\n\n| Exceptions ||\n|-----------------------|---------------------------------------|\n| `java.lang.Throwable` | the `Exception` raised by this method |"]]