Class TcpTransport

  • All Implemented Interfaces:
    RtTransport

    public class TcpTransport
    extends java.lang.Object
    implements RtTransport
    Since:
    4.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  TcpTransport.Receiver  
    • Constructor Summary

      Constructors 
      Constructor Description
      TcpTransport()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<? extends java.lang.Object> clusterMembers()
      Returns the addresses of all cluster members.
      java.lang.Object localAddress()
      Returns the local addres of this member.
      java.lang.String[] options()
      Prints the accepted options, e.g.
      void options​(java.lang.String... options)
      Sets options on this transport.
      void receiver​(RtReceiver receiver)
      Sets the receiver whose RtReceiver.receive(Object,byte[],int,int) callback will be invoked whenever a message is received
      void send​(java.lang.Object dest, byte[] buf, int offset, int length)
      Sends a message
      void start​(java.lang.String... options)
      Starts the transport, e.g.
      void stop()
      Stops the transport, e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • srv_sock

        protected java.net.ServerSocket srv_sock
      • sock

        protected java.net.Socket sock
      • output

        protected java.io.OutputStream output
      • input

        protected java.io.InputStream input
      • host

        protected java.net.InetAddress host
      • port

        protected int port
      • server

        protected boolean server
      • tcp_nodelay

        protected boolean tcp_nodelay
      • log

        protected final Log log
    • Constructor Detail

      • TcpTransport

        public TcpTransport()
    • Method Detail

      • options

        public java.lang.String[] options()
        Description copied from interface: RtTransport
        Prints the accepted options, e.g. [-host host] [-port port] [-server host]
        Specified by:
        options in interface RtTransport
        Returns:
      • options

        public void options​(java.lang.String... options)
                     throws java.lang.Exception
        Description copied from interface: RtTransport
        Sets options on this transport. Usually done after creation and before RtTransport.start(String...) is called, but may also be called at runtime.
        Specified by:
        options in interface RtTransport
        Parameters:
        options - The options
        Throws:
        java.lang.Exception
      • localAddress

        public java.lang.Object localAddress()
        Description copied from interface: RtTransport
        Returns the local addres of this member.
        Specified by:
        localAddress in interface RtTransport
        Returns:
        The local address. Implementations without cluster membership may return null
      • clusterMembers

        public java.util.List<? extends java.lang.Object> clusterMembers()
        Description copied from interface: RtTransport
        Returns the addresses of all cluster members. May return null if not implemented
        Specified by:
        clusterMembers in interface RtTransport
        Returns:
        The list of all members in the cluster
      • start

        public void start​(java.lang.String... options)
                   throws java.lang.Exception
        Description copied from interface: RtTransport
        Starts the transport, e.g. connecting to a server socket
        Specified by:
        start in interface RtTransport
        Parameters:
        options - Options passed to the transport at startup time. May be null
        Throws:
        java.lang.Exception
      • stop

        public void stop()
        Description copied from interface: RtTransport
        Stops the transport, e.g. stopping the accept() loop in a TCP-based server
        Specified by:
        stop in interface RtTransport
      • send

        public void send​(java.lang.Object dest,
                         byte[] buf,
                         int offset,
                         int length)
                  throws java.lang.Exception
        Description copied from interface: RtTransport
        Sends a message
        Specified by:
        send in interface RtTransport
        Parameters:
        dest - The destination address
        buf - The buffer
        offset - The offset at which the data starts
        length - The length (in bytes) of the data to send
        Throws:
        java.lang.Exception