|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlbnl.actor.lib.net.Server
public class Server
Server that opens a BSD socket for communication with simulation engine.
Field Summary | |
---|---|
(package private) java.net.Socket |
cliSoc
The client socket. |
protected double[] |
dblVal
The array that contains the last double values read from the socket . |
protected int |
flaFroCli
The communication flag read during the socket read command. |
private static java.lang.String |
LS
System dependent line separator |
protected java.net.ServerSocket |
serSoc
The server socket. |
protected double |
simTimRea
The current simulation time as received from the client. |
protected double |
simTimWri
The simulation time last written to the client. |
protected int |
verNo
The version number of the socket implementation. |
Constructor Summary | |
---|---|
Server(int timOut)
Construct a server on any available port. |
|
Server(int portNo,
int timOut)
Construct a server on the port specified by portNo. |
Method Summary | |
---|---|
private void |
_write(java.lang.StringBuffer strBuf)
Write the data to the socket. |
void |
close()
Close the socket. |
int |
getClientFlag()
Returns the last communication flag read from the socket. |
double[] |
getDoubleArray()
Return the last double array read from the socket. |
int |
getLocalPort()
Get the port number. |
double |
getSimulationTimeReadFromClient()
Return the last simulation time read from the client. |
double |
getSimulationTimeWrittenToClient()
Return the last simulation time written to the client. |
static void |
main(java.lang.String[] args)
Main method that can be used for testing. |
void |
read()
Read data from the socket. |
void |
write(int flagToClient,
double curTim,
double[] dblVal)
Write data to the socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.net.Socket cliSoc
protected double[] dblVal
protected int flaFroCli
protected java.net.ServerSocket serSoc
protected double simTimRea
protected double simTimWri
protected int verNo
private static final java.lang.String LS
Constructor Detail |
---|
public Server(int timOut) throws java.io.IOException
timOut
- Socket time out in milliseconds.
java.io.IOException
- If the server socket cannot be opened.public Server(int portNo, int timOut) throws java.io.IOException
portNo
- Port number for BSD socket.timOut
- Socket time out in milliseconds.
java.io.IOException
- If the server socket cannot be opened.Method Detail |
---|
public int getLocalPort()
public void write(int flagToClient, double curTim, double[] dblVal) throws java.io.IOException
flagToClient
- The communication flag.curTim
- The current simulation time.dblVal
- The array with double values.
java.io.IOException
- If a communication problems occur.private void _write(java.lang.StringBuffer strBuf) throws java.io.IOException
strBuf
- The string buffer to be sent to the socket.
java.io.IOException
- If communication problems occur.public int getClientFlag()
public double[] getDoubleArray()
public double getSimulationTimeWrittenToClient()
public double getSimulationTimeReadFromClient()
public void read() throws java.io.IOException, java.net.SocketTimeoutException
java.io.IOException
- If communication problems occur.
java.net.SocketTimeoutException
- If the socket does not respond.public void close() throws java.io.IOException
java.io.IOException
- If an I/O error occurs when closing the socket.public static void main(java.lang.String[] args) throws java.lang.Exception
args
- An array of length 1 that names the port
to be used
java.lang.Exception
- If anything goes wrong.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |