- java.lang.Object
-
- swim.io.AbstractIpSocket
-
- All Implemented Interfaces:
FlowContext,IpContext,IpSocket
public abstract class AbstractIpSocket extends Object implements IpSocket, IpContext, FlowContext
-
-
Field Summary
Fields Modifier and Type Field Description protected IpSocketContextcontext
-
Constructor Summary
Constructors Constructor Description AbstractIpSocket()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbecome(IpSocket socket)StringcipherSuite()Returns the cryptographic cipher suite used by the underlying network connection.voidclose()voiddidBecome(IpSocket 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 thisIpSocketto read input data out of the socket context'sinputBuffer.voiddoWrite()I/O callback invoked by the socket context asking thisIpSocketto 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 thisIpSocketshould be closed due to inactivity.InputBufferinputBuffer()IpSettingsipSettings()IpSocketContextipSocketContext()Returns the network socket context to which thisIpSocketis bound; returnsnullif thisIpSocketis unbound.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.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.voidsetIpSocketContext(IpSocketContext context)Sets the network socket context to which thisIpSocketis bound.voidwillBecome(IpSocket 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 IpSocketContext context
-
-
Method Detail
-
ipSocketContext
public IpSocketContext ipSocketContext()
Description copied from interface:IpSocketReturns the network socket context to which thisIpSocketis bound; returnsnullif thisIpSocketis unbound.- Specified by:
ipSocketContextin interfaceIpSocket
-
setIpSocketContext
public void setIpSocketContext(IpSocketContext context)
Description copied from interface:IpSocketSets the network socket context to which thisIpSocketis bound.- Specified by:
setIpSocketContextin interfaceIpSocket
-
idleTimeout
public long idleTimeout()
Description copied from interface:IpSocketReturns the number of idle milliseconds after which thisIpSocketshould 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 interfaceIpSocket
-
doRead
public void doRead()
Description copied from interface:IpSocketI/O callback invoked by the socket context asking thisIpSocketto 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:IpSocketI/O callback invoked by the socket context asking thisIpSocketto 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:IpSocketI/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:IpSocketLifecycle callback invoked by the socket context before the underlying network socket attempts to open a connection.- Specified by:
willConnectin interfaceIpSocket
-
didConnect
public void didConnect()
Description copied from interface:IpSocketLifecycle callback invoked by the socket context after the underlying network socket has opened a connection.- Specified by:
didConnectin interfaceIpSocket
-
willSecure
public void willSecure()
Description copied from interface:IpSocketLifecycle callback invoked by the socket context before the underlying network socket establishes a secure connection.- Specified by:
willSecurein interfaceIpSocket
-
didSecure
public void didSecure()
Description copied from interface:IpSocketLifecycle callback invoked by the socket context after the underlying network socket has established a secure connection.
-
willBecome
public void willBecome(IpSocket socket)
Description copied from interface:IpSocketLifecycle callback invoked by the socket context before it hasbecomea newsocketimplementation.- Specified by:
willBecomein interfaceIpSocket
-
didBecome
public void didBecome(IpSocket socket)
Description copied from interface:IpSocketLifecycle callback invoked by the socket context after it hasbecomea newsocketimplementation.
-
didTimeout
public void didTimeout()
Description copied from interface:IpSocketLifecycle callback invoked by the socket context after the underlying network connection has timed out. The socket will automatically be closed.- Specified by:
didTimeoutin interfaceIpSocket
-
didDisconnect
public void didDisconnect()
Description copied from interface:IpSocketLifecycle callback invoked by the socket context after the underlying network connection has disconnected.- Specified by:
didDisconnectin interfaceIpSocket
-
didFail
public void didFail(Throwable error)
Description copied from interface:IpSocketLifecycle 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:IpContextReturnstrueif the underlying network channel is currently connected.- Specified by:
isConnectedin interfaceIpContext
-
isClient
public boolean isClient()
Description copied from interface:IpContextReturnstrueif the underlying network channel initiated an outgoing connection.
-
isServer
public boolean isServer()
Description copied from interface:IpContextReturnstrueif the underlying network channel accepted an incoming connection.
-
isSecure
public boolean isSecure()
Description copied from interface:IpContextReturnstrueif the underlying network transport is encrypted.
-
securityProtocol
public String securityProtocol()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
cipherSuite
public String cipherSuite()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
localAddress
public InetSocketAddress localAddress()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
localPrincipal
public Principal localPrincipal()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
localCertificates
public Collection<Certificate> localCertificates()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
remoteAddress
public InetSocketAddress remoteAddress()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
remotePrincipal
public Principal remotePrincipal()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
remoteCertificates
public Collection<Certificate> remoteCertificates()
Description copied from interface:IpContextReturns 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 interfaceIpContext
-
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
-
ipSettings
public IpSettings ipSettings()
-
inputBuffer
public InputBuffer inputBuffer()
-
outputBuffer
public OutputBuffer<?> outputBuffer()
-
become
public void become(IpSocket socket)
-
close
public void close()
-
-