Class UnixDomainSocket
- java.lang.Object
-
- java.net.Socket
-
- org.mariadb.jdbc.client.socket.impl.UnixDomainSocket
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class UnixDomainSocket extends Socket
Unix IPC socket
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUnixDomainSocket.SockAddrSocket address
-
Constructor Summary
Constructors Constructor Description UnixDomainSocket(String path)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static intclose(int fd)Close socketstatic intconnect(int sockfd, UnixDomainSocket.SockAddr sockaddr, int addrlen)Connect socketvoidconnect(SocketAddress endpoint, int timeout)InputStreamgetInputStream()OutputStreamgetOutputStream()booleanisConnected()static intrecv(int fd, byte[] buffer, int count, int flags)Receive a message from a socketstatic intsend(int fd, byte[] buffer, int count, int flags)Send a message to a socketvoidsetKeepAlive(boolean b)voidsetSoLinger(boolean b, int i)voidsetSoTimeout(int timeout)voidsetTcpNoDelay(boolean b)voidshutdownInput()voidshutdownOutput()static intsocket(int domain, int type, int protocol)creates an endpoint for communication and returns a file descriptor that refers to that endpoint.static Stringstrerror(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, getOption, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isInputShutdown, isOutputShutdown, sendUrgentData, setOOBInline, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setTrafficClass, supportedOptions, toString
-
-
-
-
Constructor Detail
-
UnixDomainSocket
public UnixDomainSocket(String path) throws IOException
Constructor- Parameters:
path- unix path- Throws:
IOException- if any error occurs
-
-
Method Detail
-
socket
public static int socket(int domain, int type, int protocol) throws com.sun.jna.LastErrorExceptioncreates an endpoint for communication and returns a file descriptor that refers to that endpoint. see https://man7.org/linux/man-pages/man2/socket.2.html- Parameters:
domain- domaintype- typeprotocol- protocol- Returns:
- file descriptor
- Throws:
com.sun.jna.LastErrorException- if any error occurs
-
connect
public static int connect(int sockfd, UnixDomainSocket.SockAddr sockaddr, int addrlen) throws com.sun.jna.LastErrorExceptionConnect 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.LastErrorExceptionReceive a message from a socket- Parameters:
fd- file descriptorbuffer- buffercount- lengthflags- flag. see https://man7.org/linux/man-pages/man2/recvmsg.2.html- 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.LastErrorExceptionSend a message to a socket- Parameters:
fd- file descriptorbuffer- buffercount- lengthflags- flag. see https://man7.org/linux/man-pages/man2/sendmsg.2.html- 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.LastErrorExceptionClose socket- Parameters:
fd- file descriptor- Returns:
- zero on success. -1 on error
- Throws:
com.sun.jna.LastErrorException- if error occurs
-
strerror
public static String strerror(int errno)
return a description of the error code passed in the argument errnum.- Parameters:
errno- error pointer- Returns:
- error description
-
isConnected
public boolean isConnected()
- Overrides:
isConnectedin classSocket
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSocket- Throws:
IOException
-
connect
public void connect(SocketAddress endpoint, int timeout) throws IOException
- Overrides:
connectin classSocket- Throws:
IOException
-
getInputStream
public InputStream getInputStream()
- Overrides:
getInputStreamin classSocket
-
getOutputStream
public OutputStream getOutputStream()
- Overrides:
getOutputStreamin classSocket
-
setTcpNoDelay
public void setTcpNoDelay(boolean b)
- Overrides:
setTcpNoDelayin classSocket
-
setKeepAlive
public void setKeepAlive(boolean b)
- Overrides:
setKeepAlivein classSocket
-
setSoLinger
public void setSoLinger(boolean b, int i)- Overrides:
setSoLingerin classSocket
-
setSoTimeout
public void setSoTimeout(int timeout)
- Overrides:
setSoTimeoutin classSocket
-
shutdownInput
public void shutdownInput()
- Overrides:
shutdownInputin classSocket
-
shutdownOutput
public void shutdownOutput()
- Overrides:
shutdownOutputin classSocket
-
-