Rio Project 4.2 API Documentation



org.rioproject.net
Class PortRangeServerSocketFactory

java.lang.Object
  extended by javax.net.ServerSocketFactory
      extended by org.rioproject.net.PortRangeServerSocketFactory

public class PortRangeServerSocketFactory
extends ServerSocketFactory

A ServerSocketFactory that allocates ServerSockets within a port range.

NOTE: The IANA recommends the range 49152-65535, as indicated by the following document: http://www.iana.org/assignments/port-numbers


Field Summary
static int RANGE_END
           
 
Constructor Summary
PortRangeServerSocketFactory(int start)
          Creates a ServerSocketFactory that allocates ServerSockets starting from the provided port and extending to 65535
PortRangeServerSocketFactory(int start, int end)
          Creates a ServerSocketFactory that allocates ServerSockets within the given bounds (both inclusive).
 
Method Summary
 ServerSocket createServerSocket(int port)
          If the port is 0, use the provided range.
 ServerSocket createServerSocket(int port, int backlog)
          If the port is 0, use the provided range.
 ServerSocket createServerSocket(int port, int backlog, InetAddress inetAddress)
          If the port is 0, use the provided range.
 boolean equals(Object o)
           
 int getEnd()
           
 int getLastPort()
           
 int getStart()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class javax.net.ServerSocketFactory
createServerSocket, getDefault
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RANGE_END

public static final int RANGE_END
See Also:
Constant Field Values
Constructor Detail

PortRangeServerSocketFactory

public PortRangeServerSocketFactory(int start)
Creates a ServerSocketFactory that allocates ServerSockets starting from the provided port and extending to 65535

Parameters:
start - The range to start from (inclusive)
Throws:
IllegalArgumentException - is not between 0 and 65535.

PortRangeServerSocketFactory

public PortRangeServerSocketFactory(int start,
                                    int end)
Creates a ServerSocketFactory that allocates ServerSockets within the given bounds (both inclusive).

Parameters:
start - The range to start from (inclusive)
end - The end of the range (inclusive)
Throws:
IllegalArgumentException - is not between 0 and 65535, or if end is < than low.
Method Detail

getStart

public int getStart()

getEnd

public int getEnd()

getLastPort

public int getLastPort()

createServerSocket

public ServerSocket createServerSocket(int port)
                                throws IOException
If the port is 0, use the provided range. Otherwise if the port is not 0, test to make sure the port is within range.

Specified by:
createServerSocket in class ServerSocketFactory
Parameters:
port - The port to create.
Returns:
A ServerSocket bound to an available port
Throws:
IOException - If the port cannot be created.
IllegalArgumentException - if a non-zero port is provided that is outside of the range

createServerSocket

public ServerSocket createServerSocket(int port,
                                       int backlog)
                                throws IOException
If the port is 0, use the provided range. Otherwise if the port is not 0, test to make sure the port is within range.

Specified by:
createServerSocket in class ServerSocketFactory
Parameters:
port - The port to create.
backlog - The backlog, how many connections are queued
Returns:
A ServerSocket bound to an available port
Throws:
IOException - If the port cannot be created.
IllegalArgumentException - if a non-zero port is provided that is outside of the range

createServerSocket

public ServerSocket createServerSocket(int port,
                                       int backlog,
                                       InetAddress inetAddress)
                                throws IOException
If the port is 0, use the provided range. Otherwise if the port is not 0, test to make sure the port is within range.

Specified by:
createServerSocket in class ServerSocketFactory
Parameters:
port - The port to create.
backlog - The backlog, how many connections are queued
inetAddress - The network interface address to use
Returns:
A ServerSocket bound to an available port
Throws:
IOException - If the port cannot be created.
IllegalArgumentException - if a non-zero port is provided that is outside of the range

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.