Stay organized with collections
Save and categorize content based on your preferences.
SocketOption
public
interface
SocketOption
A socket option associated with a socket.
In the channels
package, the NetworkChannel
interface defines the setOption
and getOption
methods to set and query the channel's socket options.
Summary
Public methods |
abstract
String
|
name()
Returns the name of the socket option.
|
abstract
Class<T>
|
type()
Returns the type of the socket option value.
|
Public methods
name
public abstract String name ()
Returns the name of the socket option.
Returns |
String |
the name of the socket option |
type
public abstract Class<T> type ()
Returns the type of the socket option value.
Returns |
Class<T> |
the type of the socket option value |
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,["# SocketOption\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nSocketOption\n============\n\n\n`\npublic\n\n\ninterface\nSocketOption\n`\n\n\n`\n\n\n`\n\n|----------------------------|\n| java.net.SocketOption\\\u003cT\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA socket option associated with a socket.\n\nIn the [channels](/reference/java/nio/channels/package-summary) package, the [NetworkChannel](/reference/java/nio/channels/NetworkChannel) interface defines the [setOption](/reference/java/nio/channels/NetworkChannel#setOption(java.net.SocketOption\u003cT\u003e,%20T))\nand [getOption](/reference/java/nio/channels/NetworkChannel#getOption(java.net.SocketOption\u003cT\u003e))\nmethods to set and query the channel's socket options. \n**See also:**\n\n- [StandardSocketOptions](/reference/java/net/StandardSocketOptions)\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------------------------------------------|------------------------------------------------------------------------------------------------------|\n| ` abstract `[String](/reference/java/lang/String) | ` `[name](/reference/java/net/SocketOption#name())`() ` Returns the name of the socket option. |\n| ` abstract `[Class](/reference/java/lang/Class)`\u003cT\u003e` | ` `[type](/reference/java/net/SocketOption#type())`() ` Returns the type of the socket option value. |\n\nPublic methods\n--------------\n\n### name\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract String name ()\n```\n\nReturns the name of the socket option.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|--------------------------------------|\n| [String](/reference/java/lang/String) | the name of the socket option \u003cbr /\u003e |\n\n### type\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Class\u003cT\u003e type ()\n```\n\nReturns the type of the socket option value.\n\n\u003cbr /\u003e\n\n| Returns ||\n|------------------------------------------|--------------------------------------------|\n| [Class](/reference/java/lang/Class)`\u003cT\u003e` | the type of the socket option value \u003cbr /\u003e |"]]