Package jnr.unixsocket
Class UnixSocket
- 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 voidbind(SocketAddress local)voidclose()voidconnect(SocketAddress addr)voidconnect(SocketAddress addr, int timeout)SocketChannelgetChannel()CredentialsgetCredentials()Retrieves the credentials for this UNIX socket.InetAddressgetInetAddress()InputStreamgetInputStream()booleangetKeepAlive()SocketAddressgetLocalSocketAddress()OutputStreamgetOutputStream()intgetReceiveBufferSize()SocketAddressgetRemoteSocketAddress()intgetSendBufferSize()intgetSoTimeout()booleanisBound()booleanisClosed()booleanisConnected()booleanisInputShutdown()booleanisOutputShutdown()voidsetKeepAlive(boolean on)voidsetReceiveBufferSize(int size)voidsetSendBufferSize(int size)voidsetSoTimeout(int timeout)voidshutdownInput()voidshutdownOutput()-
Methods inherited from class java.net.Socket
getLocalAddress, getLocalPort, getOOBInline, getPort, getReuseAddress, getSoLinger, getTcpNoDelay, getTrafficClass, sendUrgentData, setOOBInline, setPerformancePreferences, setReuseAddress, setSocketImplFactory, setSoLinger, setTcpNoDelay, setTrafficClass, toString
-
-
-
-
Constructor Detail
-
UnixSocket
public UnixSocket(UnixSocketChannel chan)
-
-
Method Detail
-
bind
public void bind(SocketAddress local) throws IOException
- Overrides:
bindin classSocket- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSocket- Throws:
IOException
-
connect
public void connect(SocketAddress addr) throws IOException
- Overrides:
connectin classSocket- Throws:
IOException
-
connect
public void connect(SocketAddress addr, int timeout) throws IOException
- Overrides:
connectin classSocket- Throws:
IOException
-
getChannel
public SocketChannel getChannel()
- Overrides:
getChannelin classSocket
-
getInetAddress
public InetAddress getInetAddress()
- Overrides:
getInetAddressin classSocket
-
getInputStream
public InputStream getInputStream() throws IOException
- Overrides:
getInputStreamin classSocket- Throws:
IOException
-
getLocalSocketAddress
public SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classSocket
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Overrides:
getOutputStreamin classSocket- Throws:
IOException
-
getRemoteSocketAddress
public SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddressin classSocket
-
isConnected
public boolean isConnected()
- Overrides:
isConnectedin classSocket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdownin classSocket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdownin classSocket
-
shutdownInput
public void shutdownInput() throws IOException- Overrides:
shutdownInputin classSocket- Throws:
IOException
-
shutdownOutput
public void shutdownOutput() throws IOException- Overrides:
shutdownOutputin 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:
getKeepAlivein classSocket- Throws:
SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws SocketException- Overrides:
getReceiveBufferSizein classSocket- Throws:
SocketException
-
getSendBufferSize
public int getSendBufferSize() throws SocketException- Overrides:
getSendBufferSizein classSocket- Throws:
SocketException
-
getSoTimeout
public int getSoTimeout() throws SocketException- Overrides:
getSoTimeoutin classSocket- Throws:
SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws SocketException- Overrides:
setKeepAlivein classSocket- Throws:
SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws SocketException- Overrides:
setReceiveBufferSizein classSocket- Throws:
SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws SocketException- Overrides:
setSendBufferSizein classSocket- Throws:
SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws SocketException- Overrides:
setSoTimeoutin classSocket- Throws:
SocketException
-
-