public class SocketFetcher extends Object
Modifier and Type | Method and Description |
---|---|
static Socket |
getSocket(String host,
int port,
Properties props,
String prefix) |
static Socket |
getSocket(String host,
int port,
Properties props,
String prefix,
boolean useSSL)
This method returns a Socket.
|
static Socket |
startTLS(Socket socket)
Deprecated.
|
static Socket |
startTLS(Socket socket,
Properties props,
String prefix)
Deprecated.
|
static Socket |
startTLS(Socket socket,
String host,
Properties props,
String prefix)
Start TLS on an existing socket.
|
public static Socket getSocket(String host, int port, Properties props, String prefix, boolean useSSL) throws IOException
If we're making an SSL connection, the ssl.socketFactory properties are used first, if set.
If the socketFactory property is set, the value is an
instance of a SocketFactory class, not a string. The
instance is used directly. If the socketFactory property
is not set, the socketFactory.class property is considered.
(Note that the SocketFactory property must be set using the
put
method, not the setProperty
method.)
If the socketFactory.class property isn't set, the socket returned is an instance of java.net.Socket connected to the given host and port. If the socketFactory.class property is set, it is expected to contain a fully qualified classname of a javax.net.SocketFactory subclass. In this case, the class is dynamically instantiated and a socket created by that SocketFactory is returned.
If the socketFactory.fallback property is set to false, don't fall back to using regular sockets if the socket factory fails.
The socketFactory.port specifies a port to use when connecting through the socket factory. If unset, the port argument will be used.
If the connectiontimeout property is set, the timeout is passed to the socket connect method.
If the timeout property is set, it is used to set the socket timeout.
If the localaddress property is set, it's used as the local address to bind to. If the localport property is also set, it's used as the local port number to bind to.
If the usesocketchannels property is set, and we create the Socket ourself, and the selection of other properties allows, create a SocketChannel and get the Socket from it. This allows us to later retrieve the SocketChannel from the Socket and use it with Select.
host
- The host to connect toport
- The port to connect to at the hostprops
- Properties object containing socket propertiesprefix
- Property name prefix, e.g., "mail.imap"useSSL
- use the SSL socket factory as the defaultIOException
- for I/O errorspublic static Socket getSocket(String host, int port, Properties props, String prefix) throws IOException
IOException
@Deprecated public static Socket startTLS(Socket socket) throws IOException
socket
- the existing socketIOException
- for I/O errors@Deprecated public static Socket startTLS(Socket socket, Properties props, String prefix) throws IOException
socket
- the existing socketprops
- the propertiesprefix
- the property prefixIOException
- for I/O errorspublic static Socket startTLS(Socket socket, String host, Properties props, String prefix) throws IOException
socket
- the existing sockethost
- the host the socket is connected toprops
- the propertiesprefix
- the property prefixIOException
- for I/O errorsCopyright © 2017 JBoss by Red Hat. All rights reserved.