Class BasicTCP

  • Direct Known Subclasses:
    TCP, TCP_NIO

    public abstract class BasicTCP
    extends TP
    Shared base class for tcpip protocols
    Author:
    Scott Marlow
    • Field Detail

      • external_addr

        protected java.net.InetAddress external_addr
      • start_port

        protected int start_port
      • end_port

        protected int end_port
      • reaper_interval

        protected long reaper_interval
      • conn_expire_time

        protected long conn_expire_time
    • Constructor Detail

      • BasicTCP

        public BasicTCP()
    • Method Detail

      • getStartPort

        public int getStartPort()
      • setStartPort

        public void setStartPort​(int start_port)
      • getEndPort

        public int getEndPort()
      • setEndPort

        public void setEndPort​(int end_port)
      • getReaperInterval

        public long getReaperInterval()
      • setReaperInterval

        public void setReaperInterval​(long reaper_interval)
      • getConnExpireTime

        public long getConnExpireTime()
      • setConnExpireTime

        public void setConnExpireTime​(long conn_expire_time)
      • setProperties

        public boolean setProperties​(java.util.Properties props)
        Description copied from class: TP
        Setup the Protocol instance according to the configuration string
        Overrides:
        setProperties in class TP
        Returns:
        true if no other properties are left. false if the properties still have data in them, ie , properties are left over and not handled by the protocol stack
      • init

        public void init()
                  throws java.lang.Exception
        Description copied from class: Protocol
        Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
        Overrides:
        init in class TP
        Throws:
        java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception
      • sendToAllMembers

        public void sendToAllMembers​(byte[] data,
                                     int offset,
                                     int length)
                              throws java.lang.Exception
        Description copied from class: TP
        Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N messages, one for each member
        Specified by:
        sendToAllMembers in class TP
        Parameters:
        data - The data to be sent. This is not a copy, so don't modify it
        Throws:
        java.lang.Exception
      • sendToSingleMember

        public void sendToSingleMember​(Address dest,
                                       byte[] data,
                                       int offset,
                                       int length)
                                throws java.lang.Exception
        Description copied from class: TP
        Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N messages, one for each member
        Specified by:
        sendToSingleMember in class TP
        Parameters:
        dest - Must be a non-null unicast address
        data - The data to be sent. This is not a copy, so don't modify it
        Throws:
        java.lang.Exception
      • getInfo

        public java.lang.String getInfo()
        Specified by:
        getInfo in class TP
      • printConnections

        public abstract java.lang.String printConnections()
      • send

        public abstract void send​(Address dest,
                                  byte[] data,
                                  int offset,
                                  int length)
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • retainAll

        public abstract void retainAll​(java.util.Collection<Address> members)
      • receive

        public void receive​(Address sender,
                            byte[] data,
                            int offset,
                            int length)
        ConnectionTable.Receiver interface
      • handleDownEvent

        protected java.lang.Object handleDownEvent​(Event evt)
        Overrides:
        handleDownEvent in class TP