Top Description Inners Fields Constructors Methods
com.mysql.cj.protocol

public Class NamedPipeSocketFactory

extends Object
implements SocketFactory
Class Inheritance
All Implemented Interfaces
com.mysql.cj.protocol.SocketFactory, com.mysql.cj.protocol.SocketMetadata
Imports
java.io.Closeable, .FileNotFoundException, .IOException, .InputStream, .OutputStream, .RandomAccessFile, java.net.Socket, .SocketException, java.util.concurrent.TimeUnit, java.util.concurrent.locks.Lock, .ReentrantLock, com.mysql.cj.Messages, .Session, com.mysql.cj.conf.PropertyKey, .PropertySet, .RuntimeProperty, com.mysql.cj.log.Log

A socket factory for named pipes (on Windows)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
NamedPipeSocketFactory.NamedPipeSocket

A socket that encapsulates named pipes on Windows

pack-priv class
NamedPipeSocketFactory.RandomAccessFileInputStream

Enables OutputStream-type functionality for a RandomAccessFile

pack-priv class
NamedPipeSocketFactory.RandomAccessFileOutputStream

Enables OutputStream-type functionality for a RandomAccessFile

Field Summary

Modifier and TypeField and Description
private static final int
private Socket

Constructor Summary

AccessConstructor and Description
public
NamedPipeSocketFactory()

Constructor for NamedPipeSocketFactory.

Method Summary

Modifier and TypeMethod and Description
public <T extends Closeable> T
connect(String
the hostname passed in the URL. It will be a single hostname, as the driver parses multi-hosts (for failover) and calls this method for each host connection attempt.
host
,
int
the port number to connect to (if required).
portNumber
,
PropertySet
properties passed to the driver via the URL and/or properties instance.
props
,
int
login timeout in milliseconds
loginTimeout
)

Implements com.mysql.cj.protocol.SocketFactory.connect.

Creates a new socket or channel using the given properties.

public boolean
public <T extends Closeable> T
performTlsHandshake(SocketConnection
current SocketConnection
socketConnection
,
ServerSession
current ServerSession
serverSession
)

Implements com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

public <T extends Closeable> T
performTlsHandshake(SocketConnection
current SocketConnection
socketConnection
,
ServerSession
current ServerSession
serverSession
,
Log
logger
log
)

Overrides default com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_TIMEOUTback to summary
private static final int DEFAULT_TIMEOUT
namedPipeSocketback to summary
private Socket namedPipeSocket

Constructor Detail

NamedPipeSocketFactoryback to summary
public NamedPipeSocketFactory()

Constructor for NamedPipeSocketFactory.

Method Detail

connectback to summary
public <T extends Closeable> T connect(String host, int portNumber, PropertySet props, int loginTimeout) throws IOException

Implements com.mysql.cj.protocol.SocketFactory.connect.

Doc from com.mysql.cj.protocol.SocketFactory.connect.

Creates a new socket or channel using the given properties. Properties are parsed by the driver from the URL. All properties other than sensitive ones (user and password) are passed to this method. The driver will instantiate the socket factory with the class name given in the property "socketFactory", where the standard is com.mysql.cj.protocol.StandardSocketFactory Implementing classes are responsible for handling synchronization of this method (if needed).

Parameters
<T>
result type
host:String

the hostname passed in the URL. It will be a single hostname, as the driver parses multi-hosts (for failover) and calls this method for each host connection attempt.

portNumber:int

the port number to connect to (if required).

props:PropertySet

properties passed to the driver via the URL and/or properties instance.

loginTimeout:int

login timeout in milliseconds

Returns:T

a socket connected to the given host

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
IOException:
if an I/O error occurs
isLocallyConnectedback to summary
public boolean isLocallyConnected(Session sess)

Overrides default com.mysql.cj.protocol.SocketMetadata.isLocallyConnected.

Annotations
@Override
performTlsHandshakeback to summary
public <T extends Closeable> T performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession) throws IOException

Implements com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

Doc from com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Parameters
<T>
result type
socketConnection:SocketConnection

current SocketConnection

serverSession:ServerSession

current ServerSession

Returns:T

SSL socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
performTlsHandshakeback to summary
public <T extends Closeable> T performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession, Log log) throws IOException

Overrides default com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

Doc from com.mysql.cj.protocol.SocketFactory.performTlsHandshake.

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Parameters
<T>
result type
socketConnection:SocketConnection

current SocketConnection

serverSession:ServerSession

current ServerSession

log:Log

logger

Returns:T

SSL socket

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
IOException:
if an I/O error occurs
com.mysql.cj.protocol back to summary

pack-priv Class NamedPipeSocketFactory.NamedPipeSocket

extends Socket
Class Inheritance

A socket that encapsulates named pipes on Windows

Field Summary

Modifier and TypeField and Description
private boolean
private final Lock
private RandomAccessFile

Constructor Summary

AccessConstructor and Description
pack-priv
NamedPipeSocket(String filePath, int timeout)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Closes this socket.

public InputStream
getInputStream()

Overrides java.net.Socket.getInputStream.

Returns an input stream for this socket.

public OutputStream
getOutputStream()

Overrides java.net.Socket.getOutputStream.

Returns an output stream for this socket.

public boolean
isClosed()

Overrides java.net.Socket.isClosed.

Returns the closed state of the socket.

public void
shutdownInput()

Overrides java.net.Socket.shutdownInput.

Places the input stream for this socket at "end of stream".

Inherited from java.net.Socket:
bindconnectconnectgetChannelgetInetAddressgetKeepAlivegetLocalAddressgetLocalPortgetLocalSocketAddressgetOOBInlinegetOptiongetPortgetReceiveBufferSizegetRemoteSocketAddressgetReuseAddressgetSendBufferSizegetSoLingergetSoTimeoutgetTcpNoDelaygetTrafficClassisBoundisConnectedisInputShutdownisOutputShutdownsendUrgentDatasetKeepAlivesetOOBInlinesetOptionsetPerformancePreferencessetReceiveBufferSizesetReuseAddresssetSendBufferSizesetSocketImplFactorysetSoLingersetSoTimeoutsetTcpNoDelaysetTrafficClassshutdownOutputsupportedOptionstoString

Field Detail

isClosedback to summary
private boolean isClosed
lockback to summary
private final Lock lock
namedPipeFileback to summary
private RandomAccessFile namedPipeFile

Constructor Detail

NamedPipeSocketback to summary
pack-priv NamedPipeSocket(String filePath, int timeout) throws IOException

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Doc from java.net.Socket.close.

Closes this socket.

Any thread currently blocked in an I/O operation upon this socket will throw a SocketException.

Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound) and several of the methods defined by this class will throw an exception if invoked on the closed socket. A new socket needs to be created.

Closing this socket will also close the socket's InputStream and OutputStream.

If this socket has an associated channel then the channel is closed as well.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when closing this socket.
See Also
java.net.Socket#close()
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides java.net.Socket.getInputStream.

Doc from java.net.Socket.getInputStream.

Returns an input stream for this socket.

If this socket has an associated channel then the resulting input stream delegates all of its operations to the channel. If the channel is in non-blocking mode then the input stream's read operations will throw an java.nio.channels.IllegalBlockingModeException.

Reading from the input stream is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread reading from the input stream will close the underlying channel and cause the read method to throw ClosedByInterruptException with the interrupt status set.
  2. The socket uses the system-default socket implementation and a virtual thread is reading from the input stream. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. The read method will then throw SocketException with the interrupt status set.

Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream :-

  • The network software may discard bytes that are buffered by the socket. Bytes that aren't discarded by the network software can be read using read.

  • If there are no bytes buffered on the socket, or all buffered bytes have been consumed by read, then all subsequent calls to read will throw an IOException.

  • If there are no bytes buffered on the socket, and the socket has not been closed using close, then available will return 0.

Closing the returned InputStream will close the associated socket.

Returns:InputStream

an input stream for reading bytes from this socket.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the input stream, the socket is closed, the socket is not connected, or the socket input has been shutdown using shutdownInput()
See Also
java.net.Socket#getInputStream()
getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Overrides java.net.Socket.getOutputStream.

Doc from java.net.Socket.getOutputStream.

Returns an output stream for this socket.

If this socket has an associated channel then the resulting output stream delegates all of its operations to the channel. If the channel is in non-blocking mode then the output stream's write operations will throw an java.nio.channels.IllegalBlockingModeException.

Writing to the output stream is interruptible in the following circumstances:

  1. The socket is associated with a SocketChannel. In that case, interrupting a thread writing to the output stream will close the underlying channel and cause the write method to throw ClosedByInterruptException with the interrupt status set.
  2. The socket uses the system-default socket implementation and a virtual thread is writing to the output stream. In that case, interrupting the virtual thread will cause it to wakeup and close the socket. The write method will then throw SocketException with the interrupt status set.

Closing the returned OutputStream will close the associated socket.

Returns:OutputStream

an output stream for writing bytes to this socket.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the output stream, the socket is not connected or the socket is closed.
See Also
java.net.Socket#getOutputStream()
isClosedback to summary
public boolean isClosed()

Overrides java.net.Socket.isClosed.

Doc from java.net.Socket.isClosed.

Returns the closed state of the socket.

Returns:boolean

true if the socket has been closed

Annotations
@Override
See Also
java.net.Socket#isClosed()
shutdownInputback to summary
public void shutdownInput() throws IOException

Overrides java.net.Socket.shutdownInput.

Doc from java.net.Socket.shutdownInput.

Places the input stream for this socket at "end of stream". Any data sent to the input stream side of the socket is acknowledged and then silently discarded.

If you read from a socket input stream after invoking this method on the socket, the stream's available method will return 0, and its read methods will return -1 (end of stream).

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when shutting down this socket, the socket is not connected or the socket is closed.
com.mysql.cj.protocol back to summary

pack-priv Class NamedPipeSocketFactory.RandomAccessFileInputStream

extends InputStream
Class Inheritance

Enables OutputStream-type functionality for a RandomAccessFile

Field Summary

Modifier and TypeField and Description
pack-priv RandomAccessFile

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.

public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

Inherited from java.io.InputStream:
markmarkSupportednullInputStreamreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

raFileback to summary
pack-priv RandomAccessFile raFile

Constructor Detail

RandomAccessFileInputStreamback to summary
pack-priv RandomAccessFileInputStream(RandomAccessFile file)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#available()
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#close()
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#read()
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
See Also
java.io.InputStream#read(byte[])
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
See Also
java.io.InputStream#read(byte[], int, int)
com.mysql.cj.protocol back to summary

pack-priv Class NamedPipeSocketFactory.RandomAccessFileOutputStream

extends OutputStream
Class Inheritance

Enables OutputStream-type functionality for a RandomAccessFile

Field Summary

Modifier and TypeField and Description
pack-priv RandomAccessFile

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public void
write(byte[]
the data.
b
)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.

public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

Inherited from java.io.OutputStream:
flushnullOutputStream

Field Detail

raFileback to summary
pack-priv RandomAccessFile raFile

Constructor Detail

RandomAccessFileOutputStreamback to summary
pack-priv RandomAccessFileOutputStream(RandomAccessFile file)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.OutputStream#close()
writeback to summary
public void write(byte[] b) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Parameters
b:byte[]

the data.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.OutputStream#write(byte[])
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
See Also
java.io.OutputStream#write(byte[], int, int)
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
See Also
java.io.OutputStream#write(int)