Class SocketConnection
- java.lang.Object
-
- com.sun.star.lib.connections.socket.SocketConnection
-
- All Implemented Interfaces:
com.sun.star.connection.XConnection
,com.sun.star.connection.XConnectionBroadcaster
,com.sun.star.uno.XInterface
public class SocketConnection extends java.lang.Object implements com.sun.star.connection.XConnection, com.sun.star.connection.XConnectionBroadcaster
The SocketConnection implements theXConnection
interface and is uses by theSocketConnector
and theSocketAcceptor
.This class is not part of the provided
api
.- Since:
- UDK1.0
- See Also:
socketAcceptor
,socketConnector
,XConnection
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_description
protected boolean
_firstRead
protected java.io.InputStream
_inputStream
protected java.util.ArrayList<com.sun.star.io.XStreamListener>
_listeners
protected java.io.OutputStream
_outputStream
protected java.net.Socket
_socket
static boolean
DEBUG
When set to true, enables various debugging output.
-
Constructor Summary
Constructors Constructor Description SocketConnection(java.lang.String description, java.net.Socket socket)
Constructs a newSocketConnection
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStreamListener(com.sun.star.io.XStreamListener aListener)
void
close()
Closes the connection.void
flush()
Flushes the buffer.java.lang.String
getDescription()
Gives a description of the connection.int
read(byte[][] bytes, int nBytesToRead)
Read the required number of bytes.void
removeStreamListener(com.sun.star.io.XStreamListener aListener)
void
write(byte[] aData)
Write bytes.
-
-
-
Field Detail
-
DEBUG
public static final boolean DEBUG
When set to true, enables various debugging output.- See Also:
- Constant Field Values
-
_description
protected java.lang.String _description
-
_socket
protected java.net.Socket _socket
-
_inputStream
protected java.io.InputStream _inputStream
-
_outputStream
protected java.io.OutputStream _outputStream
-
_listeners
protected java.util.ArrayList<com.sun.star.io.XStreamListener> _listeners
-
_firstRead
protected boolean _firstRead
-
-
Constructor Detail
-
SocketConnection
public SocketConnection(java.lang.String description, java.net.Socket socket) throws java.io.IOException
Constructs a newSocketConnection
.- Parameters:
description
- the description of the connection.socket
- the socket of the connection.- Throws:
java.io.IOException
-
-
Method Detail
-
addStreamListener
public void addStreamListener(com.sun.star.io.XStreamListener aListener) throws com.sun.star.uno.RuntimeException
- Specified by:
addStreamListener
in interfacecom.sun.star.connection.XConnectionBroadcaster
- Throws:
com.sun.star.uno.RuntimeException
-
removeStreamListener
public void removeStreamListener(com.sun.star.io.XStreamListener aListener) throws com.sun.star.uno.RuntimeException
- Specified by:
removeStreamListener
in interfacecom.sun.star.connection.XConnectionBroadcaster
- Throws:
com.sun.star.uno.RuntimeException
-
read
public int read(byte[][] bytes, int nBytesToRead) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException
Read the required number of bytes.- Specified by:
read
in interfacecom.sun.star.connection.XConnection
- Parameters:
bytes
- the outparameter, where the bytes have to be placed.nBytesToRead
- the number of bytes to read.- Returns:
- the number of bytes read.
- Throws:
com.sun.star.io.IOException
com.sun.star.uno.RuntimeException
- See Also:
XConnection.read(byte[][], int)
-
write
public void write(byte[] aData) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException
Write bytes.- Specified by:
write
in interfacecom.sun.star.connection.XConnection
- Parameters:
aData
- the bytes to write.- Throws:
com.sun.star.io.IOException
com.sun.star.uno.RuntimeException
- See Also:
XConnection.write(byte[])
-
flush
public void flush() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException
Flushes the buffer.- Specified by:
flush
in interfacecom.sun.star.connection.XConnection
- Throws:
com.sun.star.io.IOException
com.sun.star.uno.RuntimeException
- See Also:
XConnection.flush()
-
close
public void close() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException
Closes the connection.- Specified by:
close
in interfacecom.sun.star.connection.XConnection
- Throws:
com.sun.star.io.IOException
com.sun.star.uno.RuntimeException
- See Also:
XConnection.close()
-
getDescription
public java.lang.String getDescription() throws com.sun.star.uno.RuntimeException
Gives a description of the connection.- Specified by:
getDescription
in interfacecom.sun.star.connection.XConnection
- Returns:
- the description.
- Throws:
com.sun.star.uno.RuntimeException
- See Also:
XConnection.getDescription()
-
-