- java.lang.Object
-
- java.net.Socket
-
- jnr.unixsocket.UnixSocket
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class UnixSocket extends Socket
-
-
Constructor Summary
Constructors Constructor Description UnixSocket(UnixSocketChannel chan)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(SocketAddress local)
void
close()
void
connect(SocketAddress addr)
void
connect(SocketAddress addr, int timeout)
SocketChannel
getChannel()
Credentials
getCredentials()
Retrieves the credentials for this UNIX socket.InetAddress
getInetAddress()
InputStream
getInputStream()
boolean
getKeepAlive()
SocketAddress
getLocalSocketAddress()
OutputStream
getOutputStream()
int
getReceiveBufferSize()
SocketAddress
getRemoteSocketAddress()
int
getSendBufferSize()
int
getSoTimeout()
boolean
isBound()
boolean
isClosed()
boolean
isConnected()
boolean
isInputShutdown()
boolean
isOutputShutdown()
void
setKeepAlive(boolean on)
void
setReceiveBufferSize(int size)
void
setSendBufferSize(int size)
void
setSoTimeout(int timeout)
void
shutdownInput()
void
shutdownOutput()
-
Methods inherited from class java.net.Socket
getLocalAddress, getLocalPort, getOOBInline, getOption, getPort, getReuseAddress, getSoLinger, getTcpNoDelay, getTrafficClass, sendUrgentData, setOOBInline, setOption, setPerformancePreferences, setReuseAddress, setSocketImplFactory, setSoLinger, setTcpNoDelay, setTrafficClass, supportedOptions, toString
-
-
-
-
Constructor Detail
-
UnixSocket
public UnixSocket(UnixSocketChannel chan)
-
-
Method Detail
-
bind
public void bind(SocketAddress local) throws IOException
- Overrides:
bind
in classSocket
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classSocket
- Throws:
IOException
-
connect
public void connect(SocketAddress addr) throws IOException
- Overrides:
connect
in classSocket
- Throws:
IOException
-
connect
public void connect(SocketAddress addr, int timeout) throws IOException
- Overrides:
connect
in classSocket
- Throws:
IOException
-
getChannel
public SocketChannel getChannel()
- Overrides:
getChannel
in classSocket
-
getInetAddress
public InetAddress getInetAddress()
- Overrides:
getInetAddress
in classSocket
-
getInputStream
public InputStream getInputStream() throws IOException
- Overrides:
getInputStream
in classSocket
- Throws:
IOException
-
getLocalSocketAddress
public SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddress
in classSocket
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Overrides:
getOutputStream
in classSocket
- Throws:
IOException
-
getRemoteSocketAddress
public SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddress
in classSocket
-
isConnected
public boolean isConnected()
- Overrides:
isConnected
in classSocket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdown
in classSocket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdown
in classSocket
-
shutdownInput
public void shutdownInput() throws IOException
- Overrides:
shutdownInput
in classSocket
- Throws:
IOException
-
shutdownOutput
public void shutdownOutput() throws IOException
- Overrides:
shutdownOutput
in classSocket
- Throws:
IOException
-
getCredentials
public final Credentials getCredentials() throws SocketException
Retrieves the credentials for this UNIX socket. Clients calling this method will receive the server's credentials, and servers will receive the client's credentials. User ID, group ID, and PID are supplied. See man unix 7; SCM_CREDENTIALS- Returns:
- the credentials of the remote; null if not connected
- Throws:
UnsupportedOperationException
- if the underlying socket library doesn't support the SO_PEERCRED optionSocketException
- if fetching the socket option failed.
-
getKeepAlive
public boolean getKeepAlive() throws SocketException
- Overrides:
getKeepAlive
in classSocket
- Throws:
SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws SocketException
- Overrides:
getReceiveBufferSize
in classSocket
- Throws:
SocketException
-
getSendBufferSize
public int getSendBufferSize() throws SocketException
- Overrides:
getSendBufferSize
in classSocket
- Throws:
SocketException
-
getSoTimeout
public int getSoTimeout() throws SocketException
- Overrides:
getSoTimeout
in classSocket
- Throws:
SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws SocketException
- Overrides:
setKeepAlive
in classSocket
- Throws:
SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws SocketException
- Overrides:
setReceiveBufferSize
in classSocket
- Throws:
SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws SocketException
- Overrides:
setSendBufferSize
in classSocket
- Throws:
SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws SocketException
- Overrides:
setSoTimeout
in classSocket
- Throws:
SocketException
-
-