Package fr.dyade.aaa.common.net
Class ServerSocketFactory
- java.lang.Object
-
- fr.dyade.aaa.common.net.ServerSocketFactory
-
- Direct Known Subclasses:
ServerSocketFactory13
public abstract class ServerSocketFactory extends Object
This class wraps multiples implementations of the java.net.Socket class.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDefaultFactoryThe default implementation of the ServerSocketFactory interface is for JDK since 1.4.(package private) static Loggerlogger
-
Constructor Summary
Constructors Constructor Description ServerSocketFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ServerSocketcreateServerSocket(int port, int backlog)Creates a server socket and binds it to the specified local port number, with the specified backlog.abstract ServerSocketcreateServerSocket(int port, int backlog, InetAddress addr)Create a server with the specified port, listen backlog, and local IP address to bind to.static ServerSocketFactorygetDefaultFactory()Returns the ServerSocketFactory singleton for the specified default class.static ServerSocketFactorygetFactory(String ssfcn)Returns the ServerSocketFactory singleton for the specified class.
-
-
-
Method Detail
-
getDefaultFactory
public static final ServerSocketFactory getDefaultFactory()
Returns the ServerSocketFactory singleton for the specified default class.- Returns:
- The ServerSocketFactory singleton for the default class.
-
getFactory
public static final ServerSocketFactory getFactory(String ssfcn)
Returns the ServerSocketFactory singleton for the specified class. If the specified class can not be instantiated the default one is used.- Parameters:
ssfcn- The classname for SocketFactory class.- Returns:
- The ServerSocketFactory singleton for the specified class.
-
createServerSocket
public abstract ServerSocket createServerSocket(int port, int backlog) throws IOException
Creates a server socket and binds it to the specified local port number, with the specified backlog. A port number of 0 creates a socket on any free port.- Parameters:
port- the specified port, or 0 to use any free port.backlog- the maximum length of the queue, or 0 to use the default value.- Returns:
- the created server socket.
- Throws:
IOException- if an I/O error occurs when opening the socket.- See Also:
ServerSocket(int, int)
-
createServerSocket
public abstract ServerSocket createServerSocket(int port, int backlog, InetAddress addr) throws IOException
Create a server with the specified port, listen backlog, and local IP address to bind to.The addr argument can be used on a multi-homed host for a ServerSocket that will only accept connect requests to one of its addresses. If addr is null, it will default accepting connections on any/all local addresses.
- Parameters:
port- the local TCP port, it must be between 0 and 65535, inclusive.backlog- the maximum length of the queue, or 0 to use the default value.addr- the local InetAddress the server will bind to.- Returns:
- the created server socket.
- Throws:
IOException- if an I/O error occurs when opening the socket.- See Also:
ServerSocket(int, int, InetAddress)
-
-