Top Fields Constructors Methods
org.newsclub.net.unix

pack-priv final Class AFGenericSocketImpl

extends AFSocketImpl<AFGenericSocketAddress>
Class Inheritance
Imports
java.io.FileDescriptor, java.net.SocketException

Field Summary

Inherited from org.newsclub.net.unix.AFSocketImpl:
ancillaryDataSupport

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Object
getOption(int
an int identifying the option to fetch
optID
)

Overrides org.newsclub.net.unix.AFSocketImpl.getOption.

Implements java.net.SocketOptions.getOption.

Fetch the value of an option.

public void
setOption(int
identifies the option
optID
,
Object
the parameter of the socket option
value
)

Overrides org.newsclub.net.unix.AFSocketImpl.setOption.

Implements java.net.SocketOptions.setOption.

Enable/disable the option specified by optID.

Inherited from org.newsclub.net.unix.AFSocketImpl:
acceptaccept0availablebindbindcloseconnectconnectconnectconnect0createcreateSocketensureAncillaryReceiveBufferSizegetAddressFamilygetAncillaryDataSupportgetAncillaryReceiveBufferSizegetCoregetFDgetFileDescriptorgetImplExtensionsgetInetAddressgetInputStreamgetLocalPort1getLocalSocketAddressgetOptiongetOptionDefaultgetOptionLenientgetOutputStreamgetRemotePortgetRemoteSocketAddressisBoundisClosedisConnectedlistennewInputStreamnewOutputStreamreadreceivesendsendUrgentDatasetAncillaryReceiveBufferSizesetOptionsetOptionDefaultsetOptionLenientsetSocketAddressshutdownshutdownInputshutdownOutputsupportedOptionssupportsUrgentDatatoStringupdatePortswrite

Constructor Detail

AFGenericSocketImplback to summary
pack-priv AFGenericSocketImpl(FileDescriptor fdObj)

Method Detail

getOptionback to summary
public Object getOption(int optID) throws SocketException

Overrides org.newsclub.net.unix.AFSocketImpl.getOption.

Implements java.net.SocketOptions.getOption.

Doc from java.net.SocketOptions.getOption.

Fetch the value of an option. Binary options will return Boolean#TRUE if enabled, Boolean#FALSE if disabled, e.g.:

SocketImpl s; ... Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); if (noDelay.booleanValue()) { // true if TCP_NODELAY is enabled... ... }
SocketImpl s;
...
Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY));
if (noDelay.booleanValue()) {
    // true if TCP_NODELAY is enabled...
...
}

For options that take a particular type as a parameter, this method will return the parameter's value, else it will return Boolean#FALSE:

Object o = s.getOption(SO_LINGER); if (o instanceof Integer) { System.out.print("Linger time is " + ((Integer)o).intValue()); } else { // the true type of o is java.lang.Boolean.FALSE; }
Object o = s.getOption(SO_LINGER);
if (o instanceof Integer) {
    System.out.print("Linger time is " + ((Integer)o).intValue());
} else {
  // the true type of o is java.lang.Boolean.FALSE;
}
Parameters
optID:int

an int identifying the option to fetch

Returns:Object

the value of the option

Annotations
@Override
Exceptions
SocketException:
if the socket is closed or if optID is unknown along the protocol stack
setOptionback to summary
public void setOption(int optID, Object value) throws SocketException

Overrides org.newsclub.net.unix.AFSocketImpl.setOption.

Implements java.net.SocketOptions.setOption.

Doc from java.net.SocketOptions.setOption.

Enable/disable the option specified by optID. If the option is to be enabled, and it takes an option-specific "value", this is passed in value. The actual type of value is option-specific, and it is an error to pass something that isn't of the expected type:

SocketImpl s; ... s.setOption(SO_LINGER, Integer.valueOf(10)); // OK - set SO_LINGER w/ timeout of 10 sec. s.setOption(SO_LINGER, Double.valueOf(10)); // ERROR - expects java.lang.Integer
SocketImpl s;
...
s.setOption(SO_LINGER, Integer.valueOf(10));
   // OK - set SO_LINGER w/ timeout of 10 sec.
s.setOption(SO_LINGER, Double.valueOf(10));
   // ERROR - expects java.lang.Integer
If the requested option is binary, it can be set using this method by a Boolean:
s.setOption(TCP_NODELAY, Boolean.TRUE); // OK - enables TCP_NODELAY, a binary option
s.setOption(TCP_NODELAY, Boolean.TRUE);
   // OK - enables TCP_NODELAY, a binary option
Any option can be disabled using this method with a Boolean#FALSE:
s.setOption(TCP_NODELAY, Boolean.FALSE); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, Boolean.FALSE); // OK - disables SO_LINGER
s.setOption(TCP_NODELAY, Boolean.FALSE);
   // OK - disables TCP_NODELAY
s.setOption(SO_LINGER, Boolean.FALSE);
   // OK - disables SO_LINGER
For an option that has a notion of on and off, and requires a non-boolean parameter, setting its value to anything other than Boolean#FALSE implicitly enables it.
Parameters
optID:int

identifies the option

value:Object

the parameter of the socket option

Annotations
@Override
Exceptions
SocketException:
if the option is unrecognized, the socket is closed, or some low-level error occurred