edu.utah.janosvm.kit.comm.jsi
Class TCPChannel
java.lang.Object
|
+--edu.utah.janosvm.kit.comm.jsi.TCPChannel
- All Implemented Interfaces:
- JSIChannel
- public final class TCPChannel
- extends java.lang.Object
- implements JSIChannel
A straight forward TCP implementation of a JSIChannel.
Field Summary |
private java.io.InputStream |
is
|
private byte[] |
msgSize
|
private java.io.OutputStream |
os
|
private java.net.Socket |
socket
|
Constructor Summary |
(package private) |
TCPChannel(java.net.Socket socket)
Construct a TCPChannel that runs over the given socket. |
|
TCPChannel(java.lang.String host,
int port)
Construct a TCPChannel thats connected to the given host/port. |
Method Summary |
void |
disconnect()
Disconnect the channel from its peer. |
private int |
read(byte[] buffer)
|
private int |
read(byte[] buffer,
int offset,
int length)
|
byte[] |
recvMessage()
Receive a flattened message from the peer. |
void |
replyMessage(byte[] msg)
Send a reply message to the peer. |
void |
sendMessage(byte[] msg)
Send a message to the peer. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait, wait0 |
socket
private java.net.Socket socket
is
private java.io.InputStream is
os
private java.io.OutputStream os
msgSize
private final byte[] msgSize
TCPChannel
TCPChannel(java.net.Socket socket)
throws java.io.IOException
- Construct a TCPChannel that runs over the given socket.
- Parameters:
socket
- A connected socket.
TCPChannel
public TCPChannel(java.lang.String host,
int port)
throws java.net.UnknownHostException,
java.io.IOException
- Construct a TCPChannel thats connected to the given host/port.
- Parameters:
host
- The host to connect to.port
- The port the provider is listening on.
disconnect
public void disconnect()
- Description copied from interface:
JSIChannel
- Disconnect the channel from its peer.
- Specified by:
disconnect
in interface JSIChannel
sendMessage
public void sendMessage(byte[] msg)
throws java.io.IOException
- Description copied from interface:
JSIChannel
- Send a message to the peer.
- Specified by:
sendMessage
in interface JSIChannel
- Following copied from interface:
edu.utah.janosvm.kit.comm.jsi.JSIChannel
- Parameters:
msg
- A flattened JSI message.- Throws:
Throws
- an IOException if something went wrong.
replyMessage
public void replyMessage(byte[] msg)
throws java.io.IOException
- Description copied from interface:
JSIChannel
- Send a reply message to the peer.
- Specified by:
replyMessage
in interface JSIChannel
- Following copied from interface:
edu.utah.janosvm.kit.comm.jsi.JSIChannel
- Parameters:
msg
- A flattened JSI message.- Throws:
Throws
- an IOException if something went wrong.
read
private int read(byte[] buffer,
int offset,
int length)
throws java.io.IOException
read
private int read(byte[] buffer)
throws java.io.IOException
recvMessage
public byte[] recvMessage()
throws java.io.IOException
- Description copied from interface:
JSIChannel
- Receive a flattened message from the peer.
- Specified by:
recvMessage
in interface JSIChannel
- Following copied from interface:
edu.utah.janosvm.kit.comm.jsi.JSIChannel
- Returns:
- The flattened message or null if the channel is no longer
connected.
- Throws:
Throws
- an IOException if something went wrong.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
This documentation is Copyright (C) 2000-2003 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Feb 13, 2003