|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.eyebolt.iplib.IPKey
Connection 'key' that is the connection ID.
Field Summary | |
private static int |
BUFFER_SIZE
Description of the Field |
private java.util.zip.CRC32 |
crcChecker
class to check CRC |
static int |
FAIL
Return code signifying failure. |
private boolean |
haveHeader
have we found a message header in the network stream |
private byte[] |
headerBuffer
a buffer to store received header |
private int |
headerLen
stores the length of the header of the message currently working on |
private java.io.InputStream |
inStream
input stream for socket |
private IPManager |
ipmanager
parent ipmanager instance |
private int |
key
key identifier |
private static int |
keyID
unique key identifier |
private byte[] |
messageBuffer
a receive buffer |
private int |
messageHere
# of bytes received ... |
private int |
messageSize
# of bytes received |
private boolean |
needHeader
are we currently looking for a header in the network stream |
private IPCallback |
onreceive
default observable 'callback' for unexpected traffic |
private java.io.OutputStream |
outStream
output stream for socket |
private byte[] |
receiveBuffer
a receive buffer |
private int |
receiveOffset
byte offset in locbuf that contains data |
private IPAddress |
remoteAddress
Address of the other end |
private boolean |
serverMode
flag to indicate this is a 'server' mode socket, and should be prepared to serve requests. |
private java.net.Socket |
socket
the socket for which this is a key |
static int |
SUCCESS
Return code signifying success. |
Constructor Summary | |
(package private) |
IPKey(IPManager ipm,
java.net.Socket sock,
boolean serverMode)
Construct an IPKey on a socket |
Method Summary | |
private static boolean |
_checkHdr(MessageHeader msgHdr)
Description of the Method |
(package private) void |
_distributeMsg(IPMessage msg)
Description of the Method |
(package private) int |
_isActive()
Description of the Method |
private int |
_receive_BASE()
_receive_BASE - a big honkin method to read from the stream This does message oriented receiving; receive a header, and keep receiving until the complete message arrives. |
private int |
_receive_HTTP()
_receive_HTTP - a big honkin method to read from the stream This does message oriented receiving; receive a header, and keep receiving until the complete message arrives. |
private int |
_receive_RAW()
Raw receive; just reads bytes. |
private int |
_receive_TEXT()
Receives on a socket in text mode (line oriented). |
(package private) int |
_receive()
Determines which implementation is being used, and forwards to the apropriate receive implementation. |
private void |
_send_BASE(IPMessage msg)
Description of the Method |
private void |
_send_HTTP(IPMessage msg)
Description of the Method |
private void |
_send_RAW(IPMessage msg)
Description of the Method |
private void |
_send(IPMessage msg)
Description of the Method |
void |
checkConnection()
Validate a key by excercising the connection. |
void |
disconnect()
Disconnect this connection. |
(package private) IPManager |
getIPManager()
Gets the IPManager attribute of the IPKey object |
int |
getKey()
Return an ID for this IPKey |
private static int |
getNextKeyId()
Description of the Method |
IPAddress |
getRemoteAddress()
Return the address of the remote machine. |
java.net.Socket |
getSocket()
Return a reference to the socket for which this is a key |
int |
onReceive(IPCallback cb)
Specify a callback function for messages received on this Key. |
int |
reply(IPMessage msg,
IPMessage org)
Send a Reply to a specific message |
int |
send(IPMessage msg)
Send a message (Reply, if any, goes to default Key or IPManager overall handler). |
int |
sendAndCall(IPMessage msg,
int tout,
IPCallback cb)
Send a message and notify on the observable when the reply is available |
IPMessage |
sendAndWait(IPMessage msg,
int tout)
Send a message and wait tout secs for a reply |
(package private) void |
sendDisconnect()
Send a disconnect |
(package private) void |
setRemoteAddress(IPAddress address)
Set the address of the remote machine. |
private void |
trace(byte[] bytes,
int offset,
int limit)
Write a stream of bytes to output. |
private void |
trace(java.lang.String s)
Write a trace message to standard output stream. |
private void |
updateMessageId(IPMessage msg)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int SUCCESS
public static final int FAIL
private static final int BUFFER_SIZE
private static int keyID
private IPAddress remoteAddress
private IPCallback onreceive
private IPManager ipmanager
private byte[] receiveBuffer
private byte[] messageBuffer
private int messageSize
private int messageHere
private int receiveOffset
private byte[] headerBuffer
private int headerLen
private boolean needHeader
private boolean haveHeader
private java.util.zip.CRC32 crcChecker
private java.net.Socket socket
private java.io.OutputStream outStream
private java.io.InputStream inStream
private int key
private boolean serverMode
Constructor Detail |
IPKey(IPManager ipm, java.net.Socket sock, boolean serverMode) throws java.io.IOException
ipm
- - ipmanager to which this IPKey belongssock
- - socket for which the IPKey is the keyjava.io.IOException
- Description of ExceptionMethod Detail |
IPManager getIPManager()
public int getKey()
public java.net.Socket getSocket()
public IPAddress getRemoteAddress()
void setRemoteAddress(IPAddress address)
address
- machine addresspublic void disconnect()
public int onReceive(IPCallback cb)
cb
- - A callback to be called when data is received fo this key.public IPMessage sendAndWait(IPMessage msg, int tout) throws java.io.IOException
msg
- - The message to sendtout
- - Number of seconds to wait for a replyjava.io.IOException
- if a communication error occurs.public int sendAndCall(IPMessage msg, int tout, IPCallback cb) throws java.io.IOException
msg
- - The message to sendtout
- - Number of seconds to wait for a replycb
- a callback object specifying how to call back.java.io.IOException
- if a communication error occurs.public int send(IPMessage msg) throws java.io.IOException
msg
- message to sendjava.io.IOException
- Description of Exceptionpublic int reply(IPMessage msg, IPMessage org)
msg
- This is the message that is the replyorg
- the original message (used to identify source)public void checkConnection() throws java.io.IOException
int _receive()
private int _receive_TEXT()
private int _receive_RAW()
private int _receive_BASE()
private int _receive_HTTP()
int _isActive()
void sendDisconnect()
private void updateMessageId(IPMessage msg)
private static int getNextKeyId()
final void _distributeMsg(IPMessage msg)
msg
- Description of Parameterprivate void _send(IPMessage msg) throws java.io.IOException
msg
- Description of Parameterjava.io.IOException
- Description of Exceptionprivate void _send_RAW(IPMessage msg) throws java.io.IOException
msg
- Description of Parameterjava.io.IOException
- Description of Exceptionprivate void _send_BASE(IPMessage msg) throws java.io.IOException
msg
- Description of Parameterjava.io.IOException
- Description of Exceptionprivate void _send_HTTP(IPMessage msg) throws java.io.IOException
msg
- Description of Parameterjava.io.IOException
- Description of Exceptionprivate final void trace(java.lang.String s)
s
- string to writeprivate final void trace(byte[] bytes, int offset, int limit)
buf
- bytes to writeprivate static boolean _checkHdr(MessageHeader msgHdr)
msgHdr
- Description of Parameter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |