public class SocketReader
extends java.lang.Thread
String ret = ""; String name = file.getName(); SocketReader reader = null; try { reader = new SocketReader(file, port); } catch (Throwable t) { String host = InetAddress.getLocalHost().getHostName(); throw new ConnectException ("Socket connection to "+host+":"+port+" refused"); } if (reader != null) { String host = InetAddress.getLocalHost().getHostName(); reader.start(); try { ret = server.saveBySocket(aoSession, name, subDir, host, port); reader.join(); reader = null; } catch (Throwable ttt) { ttt.printStackTrace(); } Throwable t = reader.getThrowable(); if (t != null) { if (t instanceof FileNotFoundException) { throw (FileNotFoundException)t; } else { throw (IOException)t; } } reader.close(); } return ret;
Modifier and Type | Field and Description |
---|---|
protected int |
bufSize |
protected java.net.Socket |
client |
static int |
DEFAULT_BUFSIZE
The default buffer size is 100000.
|
static int |
DEFAULT_PORT
The default port number is 11011.
|
protected java.lang.Throwable |
error |
protected java.io.File |
file |
protected java.net.ServerSocket |
serverSocket |
Constructor and Description |
---|
SocketReader(java.io.File file)
Read the data for the given file to socket with default portnumber (11011) and default buffersize (100000).
|
SocketReader(java.io.File file,
int port)
Read the data for the given file to socket using the given portnumber and default buffersize (10000).
|
SocketReader(java.io.File file,
int port,
int bufSize)
Read the data for the given file to socket using the given portnumber and buffersize.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close all open sockes, if necessary.
|
java.lang.Throwable |
getThrowable()
Get the exception that may be occurred during running method.
|
void |
run()
Start the transaction.
|
static java.lang.String |
send(CORBAFileServerIF server,
AoSession aoSession,
int port,
java.io.File file,
java.lang.String subDir)
Send the given file to the server.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final int DEFAULT_BUFSIZE
public static final int DEFAULT_PORT
protected java.net.ServerSocket serverSocket
protected java.net.Socket client
protected java.io.File file
protected java.lang.Throwable error
protected int bufSize
public SocketReader(java.io.File file) throws java.net.UnknownHostException, java.io.IOException
file
- The file to be transmitted.java.net.UnknownHostException
java.io.IOException
public SocketReader(java.io.File file, int port) throws java.net.UnknownHostException, java.io.IOException
file
- The file to be transmitted.port
- the port number to be used.java.net.UnknownHostException
java.io.IOException
public SocketReader(java.io.File file, int port, int bufSize) throws java.net.UnknownHostException, java.io.IOException
file
- The file to be transmitted.port
- the port number to be used.bufsize
- the buffer size to be used.java.net.UnknownHostException
java.io.IOException
public java.lang.Throwable getThrowable()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
getThrowable()
public void close()
public static java.lang.String send(CORBAFileServerIF server, AoSession aoSession, int port, java.io.File file, java.lang.String subDir) throws java.net.UnknownHostException, java.io.FileNotFoundException, java.net.ConnectException, java.lang.InterruptedException, java.io.IOException, CORBAFileServerException
server
- The CORABFileServer instanceaoSession
- the ASAM ODS session for the secerity check.port
- the port to used.file
- the file to be sent.subDir
- an alternative sub directory, that can be specified, if the filename should not used to determine the destination folder.java.net.UnknownHostException
java.io.FileNotFoundException
java.net.ConnectException
java.lang.InterruptedException
java.io.IOException
CORBAFileServerException