Package net.rudp

Class ReliableServerSocket

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ReliableServerSocket
    extends java.net.ServerSocket
    This class implements server sockets that use the Simple Reliable UDP (RUDP) protocol.
    Author:
    Adrian Granados
    See Also:
    ServerSocket
    • Constructor Summary

      Constructors 
      Constructor Description
      ReliableServerSocket()
      Creates an unbound RUDP server socket.
      ReliableServerSocket​(int port)
      Creates a RUDP server socket, bound to the specified port.
      ReliableServerSocket​(int port, int backlog)
      Creates a RUDP server socket and binds it to the specified local port, with the specified backlog.
      ReliableServerSocket​(int port, int backlog, java.net.InetAddress bindAddr)
      Creates a RUDP server socket and binds it to the specified local port and IP address, with the specified backlog.
      ReliableServerSocket​(java.net.DatagramSocket sock, int backlog)
      Creates a RUDP server socket attached to the specified UDP socket, with the specified backlog.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Socket accept()  
      void bind​(java.net.SocketAddress endpoint)  
      void bind​(java.net.SocketAddress endpoint, int backlog)  
      void close()  
      java.net.InetAddress getInetAddress()  
      int getLocalPort()  
      java.net.SocketAddress getLocalSocketAddress()  
      int getSoTimeout()  
      boolean isBound()  
      boolean isClosed()  
      void setSoTimeout​(int timeout)  
      • Methods inherited from class java.net.ServerSocket

        getChannel, getOption, getReceiveBufferSize, getReuseAddress, implAccept, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSocketFactory, supportedOptions, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ReliableServerSocket

        public ReliableServerSocket()
                             throws java.io.IOException
        Creates an unbound RUDP server socket.
        Throws:
        java.io.IOException - if an I/O error occurs when opening the underlying UDP socket.
        See Also:
        ServerSocket()
      • ReliableServerSocket

        public ReliableServerSocket​(int port)
                             throws java.io.IOException
        Creates a RUDP server socket, bound to the specified port. A port of 0 creates a socket on any free port.

        The maximum queue length for incoming connection indications (a request to connect) is set to 50. If a connection indication arrives when the queue is full, the connection is refused.
        Parameters:
        port - the port number, or 0 to use any free port.
        Throws:
        java.io.IOException - if an I/O error occurs when opening the underlying UDP socket.
        See Also:
        ServerSocket(int)
      • ReliableServerSocket

        public ReliableServerSocket​(int port,
                                    int backlog)
                             throws java.io.IOException
        Creates a RUDP server socket and binds it to the specified local port, with the specified backlog. A port of 0 creates a socket on any free port.
        Parameters:
        port - the port number, or 0 to use any free port.
        backlog - the listen backlog.
        Throws:
        java.io.IOException - if an I/O error occurs when opening the underlying UDP socket.
        See Also:
        ServerSocket(int, int)
      • ReliableServerSocket

        public ReliableServerSocket​(int port,
                                    int backlog,
                                    java.net.InetAddress bindAddr)
                             throws java.io.IOException
        Creates a RUDP server socket and binds it to the specified local port and IP address, with the specified backlog. The bindAddr argument can be used on a multi-homed host for a ReliableServerSocket that will only accept connect requests to one of its addresses. If bindAddr is null, it will default accepting connections on any/all local addresses. A port of 0 creates a socket on any free port.
        Parameters:
        port - the port number, or 0 to use any free port.
        backlog - the listen backlog.
        bindAddr - the local InetAddress the server will bind to.
        Throws:
        java.io.IOException - if an I/O error occurs when opening the underlying UDP socket.
        See Also:
        ServerSocket(int, int, InetAddress)
      • ReliableServerSocket

        public ReliableServerSocket​(java.net.DatagramSocket sock,
                                    int backlog)
                             throws java.io.IOException
        Creates a RUDP server socket attached to the specified UDP socket, with the specified backlog.
        Parameters:
        sock - the underlying UDP socket.
        backlog - the listen backlog.
        Throws:
        java.io.IOException - if an I/O error occurs.
    • Method Detail

      • accept

        public java.net.Socket accept()
                               throws java.io.IOException
        Overrides:
        accept in class java.net.ServerSocket
        Throws:
        java.io.IOException
      • bind

        public void bind​(java.net.SocketAddress endpoint)
                  throws java.io.IOException
        Overrides:
        bind in class java.net.ServerSocket
        Throws:
        java.io.IOException
      • bind

        public void bind​(java.net.SocketAddress endpoint,
                         int backlog)
                  throws java.io.IOException
        Overrides:
        bind in class java.net.ServerSocket
        Throws:
        java.io.IOException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.net.ServerSocket
      • getInetAddress

        public java.net.InetAddress getInetAddress()
        Overrides:
        getInetAddress in class java.net.ServerSocket
      • getLocalPort

        public int getLocalPort()
        Overrides:
        getLocalPort in class java.net.ServerSocket
      • getLocalSocketAddress

        public java.net.SocketAddress getLocalSocketAddress()
        Overrides:
        getLocalSocketAddress in class java.net.ServerSocket
      • isBound

        public boolean isBound()
        Overrides:
        isBound in class java.net.ServerSocket
      • isClosed

        public boolean isClosed()
        Overrides:
        isClosed in class java.net.ServerSocket
      • setSoTimeout

        public void setSoTimeout​(int timeout)
        Overrides:
        setSoTimeout in class java.net.ServerSocket
      • getSoTimeout

        public int getSoTimeout()
        Overrides:
        getSoTimeout in class java.net.ServerSocket