it.unimi.di.mg4j.index.remote
Class RemoteIndexServerConnection

java.lang.Object
  extended by it.unimi.di.mg4j.index.remote.RemoteIndexServerConnection
All Implemented Interfaces:
Closeable

public class RemoteIndexServerConnection
extends Object
implements Closeable

An index server connection.

Instances of this class provide a convenient way to gather all fields related to a server connection (streams, socket, etc.).

Author:
Alessandro Arrabito, Sebastiano Vigna

Field Summary
 DataInputStream inputStream
          The stream from the server.
 DataOutputStream outputStream
          The stream towards the server.
 Socket socket
           
 
Constructor Summary
RemoteIndexServerConnection(SocketAddress address, byte command)
          Creates a remote index-server connection from a given address and command.
 
Method Summary
 void close()
          Closes the underlying socket.
protected  void finalize()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

public final Socket socket

inputStream

public final DataInputStream inputStream
The stream from the server.


outputStream

public final DataOutputStream outputStream
The stream towards the server.

Constructor Detail

RemoteIndexServerConnection

public RemoteIndexServerConnection(SocketAddress address,
                                   byte command)
                            throws IOException
Creates a remote index-server connection from a given address and command.

Immediately after establishing the connection, command is sent to the server, so the stream will be connected to a thread providing a specific service. See IndexServer.

Parameters:
address - the server address.
command - the first command sent to the server (IndexServer.GET_CLIENT_INPUT_STREAM, IndexServer.GET_INDEX_READER, …).
Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Closes the underlying socket.

Specified by:
close in interface Closeable
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

toString

public String toString()
Overrides:
toString in class Object