Package net.rudp
Class ReliableServerSocket
- java.lang.Object
-
- java.net.ServerSocket
-
- net.rudp.ReliableServerSocket
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ReliableServerSocket extends java.net.ServerSocketThis class implements server sockets that use the Simple Reliable UDP (RUDP) protocol.- Author:
- Adrian Granados
- See Also:
ServerSocket
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classReliableServerSocket.ReliableClientSocket
-
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.Socketaccept()voidbind(java.net.SocketAddress endpoint)voidbind(java.net.SocketAddress endpoint, int backlog)voidclose()java.net.InetAddressgetInetAddress()intgetLocalPort()java.net.SocketAddressgetLocalSocketAddress()intgetSoTimeout()booleanisBound()booleanisClosed()voidsetSoTimeout(int timeout)
-
-
-
Constructor Detail
-
ReliableServerSocket
public ReliableServerSocket() throws java.io.IOExceptionCreates 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.IOExceptionCreates a RUDP server socket, bound to the specified port. A port of0creates a socket on any free port. The maximum queue length for incoming connection indications (a request to connect) is set to50. If a connection indication arrives when the queue is full, the connection is refused.- Parameters:
port- the port number, or0to 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.IOExceptionCreates a RUDP server socket and binds it to the specified local port, with the specified backlog. A port of0creates a socket on any free port.- Parameters:
port- the port number, or0to 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.IOExceptionCreates 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 of0creates a socket on any free port.- Parameters:
port- the port number, or0to 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.IOExceptionCreates 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:
acceptin classjava.net.ServerSocket- Throws:
java.io.IOException
-
bind
public void bind(java.net.SocketAddress endpoint) throws java.io.IOException- Overrides:
bindin classjava.net.ServerSocket- Throws:
java.io.IOException
-
bind
public void bind(java.net.SocketAddress endpoint, int backlog) throws java.io.IOException- Overrides:
bindin classjava.net.ServerSocket- Throws:
java.io.IOException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.ServerSocket
-
getInetAddress
public java.net.InetAddress getInetAddress()
- Overrides:
getInetAddressin classjava.net.ServerSocket
-
getLocalPort
public int getLocalPort()
- Overrides:
getLocalPortin classjava.net.ServerSocket
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classjava.net.ServerSocket
-
isBound
public boolean isBound()
- Overrides:
isBoundin classjava.net.ServerSocket
-
isClosed
public boolean isClosed()
- Overrides:
isClosedin classjava.net.ServerSocket
-
setSoTimeout
public void setSoTimeout(int timeout)
- Overrides:
setSoTimeoutin classjava.net.ServerSocket
-
getSoTimeout
public int getSoTimeout()
- Overrides:
getSoTimeoutin classjava.net.ServerSocket
-
-