- java.lang.Object
-
- swim.io.AbstractSocket
-
- All Implemented Interfaces:
ConnectionContext,FlowContext,Socket
public abstract class AbstractSocket extends Object implements Socket, ConnectionContext, FlowContext
-
-
Field Summary
Fields Modifier and Type Field Description protected SocketContextcontext
-
Constructor Summary
Constructors Constructor Description AbstractSocket()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbecome(Socket socket)StringcipherSuite()Returns the cryptographic cipher suite used by the underlying network connection.voidclose()voiddidBecome(Socket socket)Lifecycle callback invoked by the socket context after it hasbecomea newsocketimplementation.voiddidConnect()Lifecycle callback invoked by the socket context after the underlying network socket has opened a connection.voiddidDisconnect()Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.voiddidFail(Throwable error)Lifecycle callback invoked by the socket context when the underlying network socket fails by throwing anerror.voiddidSecure()Lifecycle callback invoked by the socket context after the underlying network socket has established a secure connection.voiddidTimeout()Lifecycle callback invoked by the socket context after the underlying network connection has timed out.voiddidWrite()I/O callback invoked by the socket context after the underlying network socket has completed writing all data in itsoutputBuffer.voiddoRead()I/O callback invoked by the socket context asking thisSocketto read input data out of the socket context'sinputBuffer.voiddoWrite()I/O callback invoked by the socket context asking thisSocketto write output data into the socket context'soutputBuffer.FlowControlflowControl()Returns the currentFlowControlstate of the underlying network channel.voidflowControl(FlowControl flowControl)Enqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl.FlowControlflowControl(FlowModifier flowModifier)Enqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifierdelta.longidleTimeout()Returns the number of idle milliseconds after which thisSocketshould be closed due to inactivity.swim.codec.InputBufferinputBuffer()booleanisClient()Returnstrueif the underlying network channel initiated an outgoing connection.booleanisConnected()Returnstrueif the underlying network channel is currently connected.booleanisSecure()Returnstrueif the underlying network transport is encrypted.booleanisServer()Returnstrueif the underlying network channel accepted an incoming connection.InetSocketAddresslocalAddress()Returns the IP address and port of the local endpoint of the underlying network connection.Collection<Certificate>localCertificates()Returns the certificate chain used to authenticate the local endpoint of the underlying network connection.PrincipallocalPrincipal()Returns the authenticated identity of the local endpoint of the underlying network connection.swim.codec.OutputBuffer<?>outputBuffer()InetSocketAddressremoteAddress()Returns the IP address and port of the remote endpoint of the underlying network connection.Collection<Certificate>remoteCertificates()Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection.PrincipalremotePrincipal()Returns the authenticated identity of the remote endpoint of the underlying network connection.StringsecurityProtocol()Returns the name of the transport-layer security protocol used by the underlying network connection.voidsetSocketContext(SocketContext context)Sets the network socket context to which thisSocketis bound.SocketContextsocketContext()Returns the network socket context to which thisSocketis bound; returnsnullif thisSocketis unbound.SocketSettingssocketSettings()voidwillBecome(Socket socket)Lifecycle callback invoked by the socket context before it hasbecomea newsocketimplementation.voidwillConnect()Lifecycle callback invoked by the socket context before the underlying network socket attempts to open a connection.voidwillSecure()Lifecycle callback invoked by the socket context before the underlying network socket establishes a secure connection.
-
-
-
Field Detail
-
context
protected SocketContext context
-
-
Method Detail
-
socketContext
public SocketContext socketContext()
Description copied from interface:SocketReturns the network socket context to which thisSocketis bound; returnsnullif thisSocketis unbound.- Specified by:
socketContextin interfaceSocket
-
setSocketContext
public void setSocketContext(SocketContext context)
Description copied from interface:SocketSets the network socket context to which thisSocketis bound.- Specified by:
setSocketContextin interfaceSocket
-
idleTimeout
public long idleTimeout()
Description copied from interface:SocketReturns the number of idle milliseconds after which thisSocketshould be closed due to inactivity. Returns-1if a default idle timeout should be used. Returns0if the underlying network socket should not time out.- Specified by:
idleTimeoutin interfaceSocket
-
doRead
public void doRead()
Description copied from interface:SocketI/O callback invoked by the socket context asking thisSocketto read input data out of the socket context'sinputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoReadcalls.
-
doWrite
public void doWrite()
Description copied from interface:SocketI/O callback invoked by the socket context asking thisSocketto write output data into the socket context'soutputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoWriteordidWritecalls.
-
didWrite
public void didWrite()
Description copied from interface:SocketI/O callback invoked by the socket context after the underlying network socket has completed writing all data in itsoutputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoWriteordidWritecalls.
-
willConnect
public void willConnect()
Description copied from interface:SocketLifecycle callback invoked by the socket context before the underlying network socket attempts to open a connection.- Specified by:
willConnectin interfaceSocket
-
didConnect
public void didConnect()
Description copied from interface:SocketLifecycle callback invoked by the socket context after the underlying network socket has opened a connection.- Specified by:
didConnectin interfaceSocket
-
willSecure
public void willSecure()
Description copied from interface:SocketLifecycle callback invoked by the socket context before the underlying network socket establishes a secure connection.- Specified by:
willSecurein interfaceSocket
-
didSecure
public void didSecure()
Description copied from interface:SocketLifecycle callback invoked by the socket context after the underlying network socket has established a secure connection.
-
willBecome
public void willBecome(Socket socket)
Description copied from interface:SocketLifecycle callback invoked by the socket context before it hasbecomea newsocketimplementation.- Specified by:
willBecomein interfaceSocket
-
didBecome
public void didBecome(Socket socket)
Description copied from interface:SocketLifecycle callback invoked by the socket context after it hasbecomea newsocketimplementation.
-
didTimeout
public void didTimeout()
Description copied from interface:SocketLifecycle callback invoked by the socket context after the underlying network connection has timed out. The socket will automatically be closed.- Specified by:
didTimeoutin interfaceSocket
-
didDisconnect
public void didDisconnect()
Description copied from interface:SocketLifecycle callback invoked by the socket context after the underlying network connection has disconnected.- Specified by:
didDisconnectin interfaceSocket
-
didFail
public void didFail(Throwable error)
Description copied from interface:SocketLifecycle callback invoked by the socket context when the underlying network socket fails by throwing anerror. The socket will automatically be closed.
-
isConnected
public boolean isConnected()
Description copied from interface:ConnectionContextReturnstrueif the underlying network channel is currently connected.- Specified by:
isConnectedin interfaceConnectionContext
-
isClient
public boolean isClient()
Description copied from interface:ConnectionContextReturnstrueif the underlying network channel initiated an outgoing connection.- Specified by:
isClientin interfaceConnectionContext
-
isServer
public boolean isServer()
Description copied from interface:ConnectionContextReturnstrueif the underlying network channel accepted an incoming connection.- Specified by:
isServerin interfaceConnectionContext
-
isSecure
public boolean isSecure()
Description copied from interface:ConnectionContextReturnstrueif the underlying network transport is encrypted.- Specified by:
isSecurein interfaceConnectionContext
-
securityProtocol
public String securityProtocol()
Description copied from interface:ConnectionContextReturns the name of the transport-layer security protocol used by the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not secure.- Specified by:
securityProtocolin interfaceConnectionContext
-
cipherSuite
public String cipherSuite()
Description copied from interface:ConnectionContextReturns the cryptographic cipher suite used by the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not secure.- Specified by:
cipherSuitein interfaceConnectionContext
-
localAddress
public InetSocketAddress localAddress()
Description copied from interface:ConnectionContextReturns the IP address and port of the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected.- Specified by:
localAddressin interfaceConnectionContext
-
localPrincipal
public Principal localPrincipal()
Description copied from interface:ConnectionContextReturns the authenticated identity of the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
localPrincipalin interfaceConnectionContext
-
localCertificates
public Collection<Certificate> localCertificates()
Description copied from interface:ConnectionContextReturns the certificate chain used to authenticate the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
localCertificatesin interfaceConnectionContext
-
remoteAddress
public InetSocketAddress remoteAddress()
Description copied from interface:ConnectionContextReturns the IP address and port of the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected.- Specified by:
remoteAddressin interfaceConnectionContext
-
remotePrincipal
public Principal remotePrincipal()
Description copied from interface:ConnectionContextReturns the authenticated identity of the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
remotePrincipalin interfaceConnectionContext
-
remoteCertificates
public Collection<Certificate> remoteCertificates()
Description copied from interface:ConnectionContextReturns the certificate chain used to authenticate the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
remoteCertificatesin interfaceConnectionContext
-
flowControl
public FlowControl flowControl()
Description copied from interface:FlowContextReturns the currentFlowControlstate of the underlying network channel.- Specified by:
flowControlin interfaceFlowContext
-
flowControl
public void flowControl(FlowControl flowControl)
Description copied from interface:FlowContextEnqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl.- Specified by:
flowControlin interfaceFlowContext
-
flowControl
public FlowControl flowControl(FlowModifier flowModifier)
Description copied from interface:FlowContextEnqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifierdelta.- Specified by:
flowControlin interfaceFlowContext
-
socketSettings
public SocketSettings socketSettings()
-
inputBuffer
public swim.codec.InputBuffer inputBuffer()
-
outputBuffer
public swim.codec.OutputBuffer<?> outputBuffer()
-
become
public void become(Socket socket)
-
close
public void close()
-
-