- java.lang.Object
-
- javax.net.ServerSocketFactory
-
- Direct Known Subclasses:
- SSLServerSocketFactory
public abstract class ServerSocketFactory extends Object
This class creates server sockets. It may be subclassed by other factories, which create particular types of server sockets. This provides a general framework for the addition of public socket-level functionality. It is the server side analogue of a socket factory, and similarly provides a way to capture a variety of policies related to the sockets being constructed.Like socket factories, server Socket factory instances have methods used to create sockets. There is also an environment specific default server socket factory; frameworks will often use their own customized factory.
- Since:
- 1.4
- See Also:
SocketFactory
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
ServerSocketFactory()
Creates a server socket factory.
-
Method Summary
Methods Modifier and Type Method and Description ServerSocket
createServerSocket()
Returns an unbound server socket.abstract ServerSocket
createServerSocket(int port)
Returns a server socket bound to the specified port.abstract ServerSocket
createServerSocket(int port, int backlog)
Returns a server socket bound to the specified port, and uses the specified connection backlog.abstract ServerSocket
createServerSocket(int port, int backlog, InetAddress ifAddress)
Returns a server socket bound to the specified port, with a specified listen backlog and local IP.static ServerSocketFactory
getDefault()
Returns a copy of the environment's default socket factory.
-
-
-
Constructor Detail
-
ServerSocketFactory
protected ServerSocketFactory()
Creates a server socket factory.
-
-
Method Detail
-
getDefault
public static ServerSocketFactory getDefault()
Returns a copy of the environment's default socket factory.- Returns:
- the
ServerSocketFactory
-
createServerSocket
public ServerSocket createServerSocket() throws IOException
Returns an unbound server socket. The socket is configured with the socket options (such as accept timeout) given to this factory.- Returns:
- the unbound socket
- Throws:
IOException
- if the socket cannot be created- See Also:
ServerSocket.bind(java.net.SocketAddress)
,ServerSocket.bind(java.net.SocketAddress, int)
,ServerSocket.ServerSocket()
-
createServerSocket
public abstract ServerSocket createServerSocket(int port) throws IOException
Returns a server socket bound to the specified port. The socket is configured with the socket options (such as accept timeout) given to this factory.If there is a security manager, its
checkListen
method is called with theport
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.- Parameters:
port
- the port to listen to- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsSecurityException
- if a security manager exists and itscheckListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
SecurityManager.checkListen(int)
,ServerSocket.ServerSocket(int)
-
createServerSocket
public abstract ServerSocket createServerSocket(int port, int backlog) throws IOException
Returns a server socket bound to the specified port, and uses the specified connection backlog. The socket is configured with the socket options (such as accept timeout) given to this factory.The
backlog
argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.If there is a security manager, its
checkListen
method is called with theport
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.- Parameters:
port
- the port to listen tobacklog
- how many connections are queued- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsSecurityException
- if a security manager exists and itscheckListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
SecurityManager.checkListen(int)
,ServerSocket.ServerSocket(int, int)
-
createServerSocket
public abstract ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
Returns a server socket bound to the specified port, with a specified listen backlog and local IP.The
ifAddress
argument can be used on a multi-homed host for aServerSocket
that will only accept connect requests to one of its addresses. IfifAddress
is null, it will accept connections on all local addresses. The socket is configured with the socket options (such as accept timeout) given to this factory.The
backlog
argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.If there is a security manager, its
checkListen
method is called with theport
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.- Parameters:
port
- the port to listen tobacklog
- how many connections are queuedifAddress
- the network interface address to use- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsSecurityException
- if a security manager exists and itscheckListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
SecurityManager.checkListen(int)
,ServerSocket.ServerSocket(int, int, java.net.InetAddress)
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/net/ServerSocketFactory.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.