Class UnixDomainSocket
java.lang.Object
java.net.Socket
org.mariadb.jdbc.client.socket.impl.UnixDomainSocket
- All Implemented Interfaces:
Closeable
,AutoCloseable
Unix IPC socket
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Socket address(package private) class
(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final AtomicBoolean
private boolean
private final int
private InputStream
private OutputStream
private static final int
private static final int
private final UnixDomainSocket.SockAddr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static int
close
(int fd) Close socketstatic int
connect
(int sockfd, UnixDomainSocket.SockAddr sockaddr, int addrlen) Connect socketvoid
connect
(SocketAddress endpoint, int timeout) private static String
formatError
(com.sun.jna.LastErrorException lee) boolean
static int
recv
(int fd, byte[] buffer, int count, int flags) Receive a message from a socketstatic int
send
(int fd, byte[] buffer, int count, int flags) Send a message to a socketvoid
setKeepAlive
(boolean b) void
setSoLinger
(boolean b, int i) void
setSoTimeout
(int timeout) void
setTcpNoDelay
(boolean b) void
void
static int
socket
(int domain, int type, int protocol) creates an endpoint for communication and returns a file descriptor that refers to that endpoint.static String
strerror
(int errno) return a description of the error code passed in the argument errnum.Methods inherited from class java.net.Socket
bind, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isInputShutdown, isOutputShutdown, sendUrgentData, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setTrafficClass, toString
-
Field Details
-
AF_UNIX
private static final int AF_UNIX- See Also:
-
SOCK_STREAM
private static final int SOCK_STREAM- See Also:
-
PROTOCOL
private static final int PROTOCOL- See Also:
-
closeLock
-
sockaddr
-
fd
private final int fd -
is
-
os
-
connected
private boolean connected
-
-
Constructor Details
-
UnixDomainSocket
Constructor- Parameters:
path
- unix path- Throws:
IOException
- if any error occurs
-
-
Method Details
-
socket
public static int socket(int domain, int type, int protocol) throws com.sun.jna.LastErrorException creates an endpoint for communication and returns a file descriptor that refers to that endpoint.- Parameters:
domain
- domaintype
- typeprotocol
- protocol- Returns:
- file descriptor
- Throws:
com.sun.jna.LastErrorException
- if any error occurs- See Also:
-
connect
public static int connect(int sockfd, UnixDomainSocket.SockAddr sockaddr, int addrlen) throws com.sun.jna.LastErrorException Connect socket- Parameters:
sockfd
- file descriptorsockaddr
- socket addressaddrlen
- address length- Returns:
- zero on success. -1 on error
- Throws:
com.sun.jna.LastErrorException
- if error occurs
-
recv
public static int recv(int fd, byte[] buffer, int count, int flags) throws com.sun.jna.LastErrorException Receive a message from a socket- Parameters:
fd
- file descriptorbuffer
- buffercount
- lengthflags
- flag. @see flags- Returns:
- zero on success. -1 on error
- Throws:
com.sun.jna.LastErrorException
- if error occurs
-
send
public static int send(int fd, byte[] buffer, int count, int flags) throws com.sun.jna.LastErrorException Send a message to a socket- Parameters:
fd
- file descriptorbuffer
- buffercount
- lengthflags
- flag. @see flags- Returns:
- zero on success. -1 on error
- Throws:
com.sun.jna.LastErrorException
- if error occurs
-
close
public static int close(int fd) throws com.sun.jna.LastErrorException Close socket- Parameters:
fd
- file descriptor- Returns:
- zero on success. -1 on error
- Throws:
com.sun.jna.LastErrorException
- if error occurs
-
strerror
return a description of the error code passed in the argument errnum.- Parameters:
errno
- error pointer- Returns:
- error description
-
formatError
-
isConnected
public boolean isConnected()- Overrides:
isConnected
in classSocket
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classSocket
- Throws:
IOException
-
connect
- Overrides:
connect
in classSocket
- Throws:
IOException
-
getInputStream
- Overrides:
getInputStream
in classSocket
-
getOutputStream
- Overrides:
getOutputStream
in classSocket
-
setTcpNoDelay
public void setTcpNoDelay(boolean b) - Overrides:
setTcpNoDelay
in classSocket
-
setKeepAlive
public void setKeepAlive(boolean b) - Overrides:
setKeepAlive
in classSocket
-
setSoLinger
public void setSoLinger(boolean b, int i) - Overrides:
setSoLinger
in classSocket
-
setSoTimeout
public void setSoTimeout(int timeout) - Overrides:
setSoTimeout
in classSocket
-
shutdownInput
public void shutdownInput()- Overrides:
shutdownInput
in classSocket
-
shutdownOutput
public void shutdownOutput()- Overrides:
shutdownOutput
in classSocket
-