cx.ath.matthew.unix

Class UnixSocket

public class UnixSocket extends Object

Represents a UnixSocket.
Constructor Summary
UnixSocket()
Create an unconnected socket.
UnixSocket(UnixSocketAddress address)
Create a socket connected to the given address.
UnixSocket(String address)
Create a socket connected to the given address.
Method Summary
voidclose()
Closes the connection.
voidconnect(UnixSocketAddress address)
Connect the socket to this address.
voidconnect(String address)
Connect the socket to this address.
voidfinalize()
UnixSocketAddressgetAddress()
Returns the address this socket is connected to.
booleangetBlocking()
Get the blocking mode.
InputStreamgetInputStream()
Returns an InputStream for reading from the socket.
OutputStreamgetOutputStream()
Returns an OutputStream for writing to the socket.
booleangetPassCred()
Get the credential passing status.
booleanisClosed()
Check the socket status.
booleanisConnected()
Check the socket status.
booleanisInputShutdown()
Check the socket status.
booleanisOutputShutdown()
Check the socket status.
voidsetBlocking(boolean enable)
Set the blocking mode.
voidsetPassCred(boolean enable)
Set the credential passing status.
voidsetSoTimeout(int timeout)
Set timeout of read requests.
voidshutdownInput()
Shuts down the input stream.
voidshutdownOutput()
Shuts down the output stream.

Constructor Detail

UnixSocket

public UnixSocket()
Create an unconnected socket.

UnixSocket

public UnixSocket(UnixSocketAddress address)
Create a socket connected to the given address.

Parameters: address The Unix Socket address to connect to

UnixSocket

public UnixSocket(String address)
Create a socket connected to the given address.

Parameters: address The Unix Socket address to connect to

Method Detail

close

public void close()
Closes the connection.

connect

public void connect(UnixSocketAddress address)
Connect the socket to this address.

Parameters: address The Unix Socket address to connect to

connect

public void connect(String address)
Connect the socket to this address.

Parameters: address The Unix Socket address to connect to

finalize

public void finalize()

getAddress

public UnixSocketAddress getAddress()
Returns the address this socket is connected to. Returns null if the socket is unconnected.

Returns: The UnixSocketAddress the socket is connected to

getBlocking

public boolean getBlocking()
Get the blocking mode.

Returns: true if reads are blocking.

See Also: setBlocking

getInputStream

public InputStream getInputStream()
Returns an InputStream for reading from the socket.

Returns: An InputStream connected to this socket.

getOutputStream

public OutputStream getOutputStream()
Returns an OutputStream for writing to the socket.

Returns: An OutputStream connected to this socket.

getPassCred

public boolean getPassCred()
Get the credential passing status.

Returns: The current status of credential passing.

See Also: setPassCred

isClosed

public boolean isClosed()
Check the socket status.

Returns: true if closed.

isConnected

public boolean isConnected()
Check the socket status.

Returns: true if connected.

isInputShutdown

public boolean isInputShutdown()
Check the socket status.

Returns: true if the input stream has been shutdown

isOutputShutdown

public boolean isOutputShutdown()
Check the socket status.

Returns: true if the output stream has been shutdown

setBlocking

public void setBlocking(boolean enable)
Set the blocking mode.

Parameters: enable Set to false for non-blocking reads.

setPassCred

public void setPassCred(boolean enable)
Set the credential passing status.

Parameters: enable Set to true for credentials to be passed.

setSoTimeout

public void setSoTimeout(int timeout)
Set timeout of read requests.

shutdownInput

public void shutdownInput()
Shuts down the input stream. Subsequent reads on the associated InputStream will fail.

shutdownOutput

public void shutdownOutput()
Shuts down the output stream. Subsequent writes to the associated OutputStream will fail.