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 void
bind(java.net.SocketAddress local)
void
close()
void
connect(java.net.SocketAddress addr)
void
connect(java.net.SocketAddress addr, int timeout)
java.nio.channels.SocketChannel
getChannel()
Credentials
getCredentials()
Retrieves the credentials for this UNIX socket.java.net.InetAddress
getInetAddress()
java.io.InputStream
getInputStream()
boolean
getKeepAlive()
java.net.SocketAddress
getLocalSocketAddress()
java.io.OutputStream
getOutputStream()
int
getReceiveBufferSize()
java.net.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(java.net.SocketAddress local) throws java.io.IOException
- Overrides:
bind
in classjava.net.Socket
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.net.Socket
- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress addr) throws java.io.IOException
- Overrides:
connect
in classjava.net.Socket
- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress addr, int timeout) throws java.io.IOException
- Overrides:
connect
in classjava.net.Socket
- Throws:
java.io.IOException
-
getChannel
public java.nio.channels.SocketChannel getChannel()
- Overrides:
getChannel
in classjava.net.Socket
-
getInetAddress
public java.net.InetAddress getInetAddress()
- Overrides:
getInetAddress
in classjava.net.Socket
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Overrides:
getInputStream
in classjava.net.Socket
- Throws:
java.io.IOException
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddress
in classjava.net.Socket
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException
- Overrides:
getOutputStream
in classjava.net.Socket
- Throws:
java.io.IOException
-
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddress
in classjava.net.Socket
-
isBound
public boolean isBound()
- Overrides:
isBound
in classjava.net.Socket
-
isClosed
public boolean isClosed()
- Overrides:
isClosed
in classjava.net.Socket
-
isConnected
public boolean isConnected()
- Overrides:
isConnected
in classjava.net.Socket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdown
in classjava.net.Socket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdown
in classjava.net.Socket
-
shutdownInput
public void shutdownInput() throws java.io.IOException
- Overrides:
shutdownInput
in classjava.net.Socket
- Throws:
java.io.IOException
-
shutdownOutput
public void shutdownOutput() throws java.io.IOException
- Overrides:
shutdownOutput
in 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:
getKeepAlive
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws java.net.SocketException
- Overrides:
getReceiveBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getSendBufferSize
public int getSendBufferSize() throws java.net.SocketException
- Overrides:
getSendBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getSoTimeout
public int getSoTimeout() throws java.net.SocketException
- Overrides:
getSoTimeout
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws java.net.SocketException
- Overrides:
setKeepAlive
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws java.net.SocketException
- Overrides:
setReceiveBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws java.net.SocketException
- Overrides:
setSendBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws java.net.SocketException
- Overrides:
setSoTimeout
in classjava.net.Socket
- Throws:
java.net.SocketException
-
-