Skip to content

Most visited

Recently visited



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 openUdpEncapsulationSocket(). The provided socket cannot be re-bound by the caller. The caller should not close the FileDescriptor returned by getSocket(), 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.


Public methods

void close()

Close this socket.

int getPort()

Get the bound port of the wrapped socket.

FileDescriptor getSocket()

Get the wrapped socket.

Protected methods

void finalize()

Check that the socket was closed properly.

Inherited methods

From class java.lang.Object
From interface java.lang.AutoCloseable

Public methods


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 IpSecManager.ResourceUnavailableException being thrown.



int getPort ()

Get the bound port of the wrapped socket.



FileDescriptor getSocket ()

Get the wrapped socket.


Protected methods


void finalize ()

Check that the socket was closed properly.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)