datasource
Class NetSource
java.lang.Object
datasource.DataSource
datasource.NetSource
public class NetSource
- extends DataSource
A NetSource is a source that reads a file (sequentially).
To allow code that runs more than one trial in a single run,
the server changes its port each trial, by successive adding +1, -1, +1, ...
to the base port number passed as a constructor argument.
(If it doesn't change port number, the client could connect twice
to it before it has finished the first request, which it's not prepared to
do).
- Version:
- $Id: NetSource.java,v 1.8 2010/01/06 01:49:31 zahorjan Exp $
Method Summary |
private void |
close()
Closes the socket, and updates the port number to prepare
for being reInit()'ed |
protected int |
readFromSrc(byte[] buf,
int len)
Called by reader thread in DataSource object. |
void |
reInit()
(Re)Initialize this object |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
portIncrement
private int portIncrement
port
private int port
serverSocket
private java.net.ServerSocket serverSocket
clientSocket
private java.net.Socket clientSocket
inStream
private java.io.InputStream inStream
haveConnection
private boolean haveConnection
NetSource
public NetSource(int baseport)
reInit
public void reInit()
throws java.io.IOException
- (Re)Initialize this object
- Specified by:
reInit
in class DataSource
- Throws:
java.io.IOException
readFromSrc
protected int readFromSrc(byte[] buf,
int len)
throws java.io.IOException
- Called by reader thread in DataSource object.
- Specified by:
readFromSrc
in class DataSource
- Throws:
java.io.IOException
close
private void close()
throws java.io.IOException
- Closes the socket, and updates the port number to prepare
for being reInit()'ed
- Throws:
java.io.IOException