Module swim.io
Package swim.io

Class IpSocketModem<I,​O>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void become​(IpSocket socket)
      Rebinds the underlying IpSocketContext to a new socket implementation, thereby changing the IpSocket handler that receives network I/O callbacks.
      String cipherSuite()
      Returns the cryptographic cipher suite used by the underlying network connection.
      void close()
      Closes the underlying network socket.
      void didBecome​(IpSocket socket)
      Lifecycle callback invoked by the socket context after it has become a new socket implementation.
      void didConnect()
      Lifecycle callback invoked by the socket context after the underlying network socket has opened a connection.
      void didDisconnect()
      Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
      void didFail​(Throwable error)
      Lifecycle callback invoked by the socket context when the underlying network socket fails by throwing an error.
      void didSecure()
      Lifecycle callback invoked by the socket context after the underlying network socket has established a secure connection.
      void didTimeout()
      Lifecycle callback invoked by the socket context after the underlying network connection has timed out.
      void didWrite()
      I/O callback invoked by the socket context after the underlying network socket has completed writing all data in its outputBuffer.
      void doRead()
      I/O callback invoked by the socket context asking this IpSocket to read input data out of the socket context's inputBuffer.
      void doWrite()
      I/O callback invoked by the socket context asking this IpSocket to write output data into the socket context's outputBuffer.
      FlowControl flowControl()
      Returns the current FlowControl state of the underlying network channel.
      void flowControl​(FlowControl flowControl)
      Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
      FlowControl flowControl​(FlowModifier flowModifier)
      Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
      long idleTimeout()
      Returns the number of idle milliseconds after which this IpSocket should be closed due to inactivity.
      IpSettings ipSettings()
      Returns the configuration parameters that govern the underlying network socket.
      IpSocketContext ipSocketContext()
      Returns the network socket context to which this IpSocket is bound; returns null if this IpSocket is unbound.
      boolean isClient()
      Returns true if the underlying network channel initiated an outgoing connection.
      boolean isConnected()
      Returns true if the underlying network channel is currently connected.
      boolean isSecure()
      Returns true if the underlying network transport is encrypted.
      boolean isServer()
      Returns true if the underlying network channel accepted an incoming connection.
      InetSocketAddress localAddress()
      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.
      Principal localPrincipal()
      Returns the authenticated identity of the local endpoint of the underlying network connection.
      <I2 extends I>
      void
      read​(Decoder<I2> reader)
      Enqueues a read decoder to which input data will be asynchronously fed.
      InetSocketAddress remoteAddress()
      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.
      Principal remotePrincipal()
      Returns the authenticated identity of the remote endpoint of the underlying network connection.
      String securityProtocol()
      Returns the name of the transport-layer security protocol used by the underlying network connection.
      void setIpSocketContext​(IpSocketContext context)
      Sets the network socket context to which this IpSocket is bound.
      void willBecome​(IpSocket socket)
      Lifecycle callback invoked by the socket context before it has become a new socket implementation.
      void willConnect()
      Lifecycle callback invoked by the socket context before the underlying network socket attempts to open a connection.
      void willSecure()
      Lifecycle callback invoked by the socket context before the underlying network socket establishes a secure connection.
      <O2 extends O>
      void
      write​(Encoder<?,​O2> writer)
      Enqueues a write encoder from which output data will be asynchronously pulled.
    • Constructor Detail

      • IpSocketModem

        public IpSocketModem​(IpModem<I,​O> modem)
    • Method Detail

      • ipSocketContext

        public IpSocketContext ipSocketContext()
        Description copied from interface: IpSocket
        Returns the network socket context to which this IpSocket is bound; returns null if this IpSocket is unbound.
        Specified by:
        ipSocketContext in interface IpSocket
      • setIpSocketContext

        public void setIpSocketContext​(IpSocketContext context)
        Description copied from interface: IpSocket
        Sets the network socket context to which this IpSocket is bound.
        Specified by:
        setIpSocketContext in interface IpSocket
      • isConnected

        public boolean isConnected()
        Description copied from interface: IpContext
        Returns true if the underlying network channel is currently connected.
        Specified by:
        isConnected in interface IpContext
      • isClient

        public boolean isClient()
        Description copied from interface: IpContext
        Returns true if the underlying network channel initiated an outgoing connection.
        Specified by:
        isClient in interface IpContext
      • isServer

        public boolean isServer()
        Description copied from interface: IpContext
        Returns true if the underlying network channel accepted an incoming connection.
        Specified by:
        isServer in interface IpContext
      • isSecure

        public boolean isSecure()
        Description copied from interface: IpContext
        Returns true if the underlying network transport is encrypted.
        Specified by:
        isSecure in interface IpContext
      • securityProtocol

        public String securityProtocol()
        Description copied from interface: IpContext
        Returns the name of the transport-layer security protocol used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
        Specified by:
        securityProtocol in interface IpContext
      • cipherSuite

        public String cipherSuite()
        Description copied from interface: IpContext
        Returns the cryptographic cipher suite used by the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not secure.
        Specified by:
        cipherSuite in interface IpContext
      • localAddress

        public InetSocketAddress localAddress()
        Description copied from interface: IpContext
        Returns the IP address and port of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
        Specified by:
        localAddress in interface IpContext
      • localPrincipal

        public Principal localPrincipal()
        Description copied from interface: IpContext
        Returns the authenticated identity of the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        localPrincipal in interface IpContext
      • localCertificates

        public Collection<Certificate> localCertificates()
        Description copied from interface: IpContext
        Returns the certificate chain used to authenticate the local endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        localCertificates in interface IpContext
      • remoteAddress

        public InetSocketAddress remoteAddress()
        Description copied from interface: IpContext
        Returns the IP address and port of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected.
        Specified by:
        remoteAddress in interface IpContext
      • remotePrincipal

        public Principal remotePrincipal()
        Description copied from interface: IpContext
        Returns the authenticated identity of the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        remotePrincipal in interface IpContext
      • remoteCertificates

        public Collection<Certificate> remoteCertificates()
        Description copied from interface: IpContext
        Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection. Returns null if the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.
        Specified by:
        remoteCertificates in interface IpContext
      • read

        public <I2 extends I> void read​(Decoder<I2> reader)
        Description copied from interface: IpModemContext
        Enqueues a read decoder to which input data will be asynchronously fed. The read flow control of the underlying network socket is automatically managed using the state of the read decoder. When the read decoder transitions into the done state, the didRead callback of the bound IpModem will be invoked with the decoded result. If the read decoder transitions into the error state, then the didFail callback of the bound IpModem will be invoked with the decode error.
        Specified by:
        read in interface IpModemContext<I,​O>
      • write

        public <O2 extends O> void write​(Encoder<?,​O2> writer)
        Description copied from interface: IpModemContext
        Enqueues a write encoder from which output data will be asynchronously pulled. The write flow control of the underlying network socket is automatically managed using the state of the write encoder. When the write encoder transitions into the done state, the didWrite callback of the bound IpModem will be invoked with the encoded result. If the write encoder transitions into the error state, then the didFail callback of the bound IpModem will be invoked with the encode error.
        Specified by:
        write in interface IpModemContext<I,​O>
      • idleTimeout

        public long idleTimeout()
        Description copied from interface: IpSocket
        Returns the number of idle milliseconds after which this IpSocket should be closed due to inactivity. Returns -1 if a default idle timeout should be used. Returns 0 if the underlying network socket should not time out.
        Specified by:
        idleTimeout in interface IpSocket
      • doRead

        public void doRead()
        Description copied from interface: IpSocket
        I/O callback invoked by the socket context asking this IpSocket to read input data out of the socket context's inputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with other doRead calls.
        Specified by:
        doRead in interface IpSocket
      • doWrite

        public void doWrite()
        Description copied from interface: IpSocket
        I/O callback invoked by the socket context asking this IpSocket to write output data into the socket context's outputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with other doWrite or didWrite calls.
        Specified by:
        doWrite in interface IpSocket
      • didWrite

        public void didWrite()
        Description copied from interface: IpSocket
        I/O callback invoked by the socket context after the underlying network socket has completed writing all data in its outputBuffer. May be invoked concurrently to other I/O callbacks, but never concurrently with other doWrite or didWrite calls.
        Specified by:
        didWrite in interface IpSocket
      • willConnect

        public void willConnect()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context before the underlying network socket attempts to open a connection.
        Specified by:
        willConnect in interface IpSocket
      • didConnect

        public void didConnect()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context after the underlying network socket has opened a connection.
        Specified by:
        didConnect in interface IpSocket
      • willSecure

        public void willSecure()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context before the underlying network socket establishes a secure connection.
        Specified by:
        willSecure in interface IpSocket
      • didSecure

        public void didSecure()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context after the underlying network socket has established a secure connection.
        Specified by:
        didSecure in interface IpSocket
      • willBecome

        public void willBecome​(IpSocket socket)
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context before it has become a new socket implementation.
        Specified by:
        willBecome in interface IpSocket
      • didBecome

        public void didBecome​(IpSocket socket)
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context after it has become a new socket implementation.
        Specified by:
        didBecome in interface IpSocket
      • didTimeout

        public void didTimeout()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context after the underlying network connection has timed out. The socket will automatically be closed.
        Specified by:
        didTimeout in interface IpSocket
      • didDisconnect

        public void didDisconnect()
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.
        Specified by:
        didDisconnect in interface IpSocket
      • didFail

        public void didFail​(Throwable error)
        Description copied from interface: IpSocket
        Lifecycle callback invoked by the socket context when the underlying network socket fails by throwing an error. The socket will automatically be closed.
        Specified by:
        didFail in interface IpSocket
      • flowControl

        public FlowControl flowControl()
        Description copied from interface: FlowContext
        Returns the current FlowControl state of the underlying network channel.
        Specified by:
        flowControl in interface FlowContext
      • flowControl

        public void flowControl​(FlowControl flowControl)
        Description copied from interface: FlowContext
        Enqueues an atomic replacement of the underlying network channel's flow control state with a new flowControl.
        Specified by:
        flowControl in interface FlowContext
      • flowControl

        public FlowControl flowControl​(FlowModifier flowModifier)
        Description copied from interface: FlowContext
        Enqueues an atomic modification to the underlying network channel's flow control state by applying a flowModifier delta.
        Specified by:
        flowControl in interface FlowContext
      • become

        public void become​(IpSocket socket)
        Description copied from interface: IpModemContext
        Rebinds the underlying IpSocketContext to a new socket implementation, thereby changing the IpSocket handler that receives network I/O callbacks.
        Specified by:
        become in interface IpModemContext<I,​O>
      • close

        public void close()
        Description copied from interface: IpModemContext
        Closes the underlying network socket.
        Specified by:
        close in interface IpModemContext<I,​O>