Package jnr.unixsocket
Class UnixSocket
- java.lang.Object
-
- java.net.Socket
-
- jnr.unixsocket.UnixSocket
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class UnixSocket extends java.net.Socket
-
-
Constructor Summary
Constructors Constructor Description UnixSocket(UnixSocketChannel chan)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(java.net.SocketAddress local)voidclose()voidconnect(java.net.SocketAddress addr)voidconnect(java.net.SocketAddress addr, int timeout)java.nio.channels.SocketChannelgetChannel()CredentialsgetCredentials()Retrieves the credentials for this UNIX socket.java.net.InetAddressgetInetAddress()java.io.InputStreamgetInputStream()booleangetKeepAlive()java.net.SocketAddressgetLocalSocketAddress()java.io.OutputStreamgetOutputStream()intgetReceiveBufferSize()java.net.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, 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(java.net.SocketAddress local) throws java.io.IOException- Overrides:
bindin classjava.net.Socket- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.Socket- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress addr) throws java.io.IOException- Overrides:
connectin classjava.net.Socket- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress addr, int timeout) throws java.io.IOException- Overrides:
connectin classjava.net.Socket- Throws:
java.io.IOException
-
getChannel
public java.nio.channels.SocketChannel getChannel()
- Overrides:
getChannelin classjava.net.Socket
-
getInetAddress
public java.net.InetAddress getInetAddress()
- Overrides:
getInetAddressin classjava.net.Socket
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Overrides:
getInputStreamin classjava.net.Socket- Throws:
java.io.IOException
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classjava.net.Socket
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException- Overrides:
getOutputStreamin classjava.net.Socket- Throws:
java.io.IOException
-
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddressin classjava.net.Socket
-
isBound
public boolean isBound()
- Overrides:
isBoundin classjava.net.Socket
-
isClosed
public boolean isClosed()
- Overrides:
isClosedin classjava.net.Socket
-
isConnected
public boolean isConnected()
- Overrides:
isConnectedin classjava.net.Socket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdownin classjava.net.Socket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdownin classjava.net.Socket
-
shutdownInput
public void shutdownInput() throws java.io.IOException- Overrides:
shutdownInputin classjava.net.Socket- Throws:
java.io.IOException
-
shutdownOutput
public void shutdownOutput() throws java.io.IOException- Overrides:
shutdownOutputin classjava.net.Socket- Throws:
java.io.IOException
-
getCredentials
public final Credentials getCredentials() throws java.net.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:
java.lang.UnsupportedOperationException- if the underlying socket library doesn't support the SO_PEERCRED optionjava.net.SocketException- if fetching the socket option failed.
-
getKeepAlive
public boolean getKeepAlive() throws java.net.SocketException- Overrides:
getKeepAlivein classjava.net.Socket- Throws:
java.net.SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws java.net.SocketException- Overrides:
getReceiveBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
getSendBufferSize
public int getSendBufferSize() throws java.net.SocketException- Overrides:
getSendBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
getSoTimeout
public int getSoTimeout() throws java.net.SocketException- Overrides:
getSoTimeoutin classjava.net.Socket- Throws:
java.net.SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws java.net.SocketException- Overrides:
setKeepAlivein classjava.net.Socket- Throws:
java.net.SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws java.net.SocketException- Overrides:
setReceiveBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws java.net.SocketException- Overrides:
setSendBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws java.net.SocketException- Overrides:
setSoTimeoutin classjava.net.Socket- Throws:
java.net.SocketException
-
-