public class SSLSocket extends Socket
DEFAULT_OPEN_TIMEOUT, DEFAULT_READ_TIMEOUT, DEFAULT_WRITE_TIMEOUT, readTimeout, writeTimeout
skipBuffer
Constructor and Description |
---|
SSLSocket(java.lang.String host,
int port,
int timeout)
Constructs an SSL connection to a named host at a specified port, with the specified connection timeout, binding
the client side of the connection a given address and port.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the socket.
|
protected SSLClient |
prepareContext()
Creates a new SSLClient to be used by this instance of SSLSocket during the handshake.
|
int |
readBytes(byte[] buf)
Reads bytes from the socket into a byte array, from offset 0 to
buf.length.
|
int |
readBytes(byte[] buf,
int start,
int count)
Reads bytes from the socket into a byte array.
|
void |
startHandshake()
Starts an SSL handshake on this connection.
|
int |
writeBytes(byte[] buf,
int start,
int count)
Writes to the socket.
|
finalize, getHost, getNativeSocket, getPort, readLine
asInputStream, asOutputStream, asStream, asStream, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytes, writeBytes
public SSLSocket(java.lang.String host, int port, int timeout) throws UnknownHostException, IOException
host
- the server's hostport
- its porttimeout
- the timeout for this operationUnknownHostException
- if the host is not knownIOException
- if an I/O error occurs when creating the socketprotected SSLClient prepareContext() throws CryptoException
CryptoException
public void startHandshake() throws IOException
IOException
- on a network level errorpublic int readBytes(byte[] buf, int start, int count) throws IOException
Socket
readBytes
in class Socket
buf
- the byte array to read data intostart
- the start position in the byte arraycount
- the number of bytes to readIOException
public int readBytes(byte[] buf) throws IOException
Socket
readBytes
in class Socket
buf
- the byte array to read data intoIOException
Socket.readBytes(byte[], int, int)
public int writeBytes(byte[] buf, int start, int count) throws IOException
Socket
writeBytes
in class Socket
buf
- the byte array to write data fromstart
- the start position in the byte arraycount
- the number of bytes to writeIOException
public void close() throws IOException
Socket
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class Socket
IOException
- If an I/O error occurs.