|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectsquint.TCPConnection
public class TCPConnection
TCPConnection is a class that implements a data connection that supports the transmission of binary and text data through the Internet to and from a program and a port on a remote computer.
| Field Summary | |
|---|---|
DataInputChannel |
in
Used to access data received through this connection |
DataOutputChannel |
out
Used to send data through this connection |
| Constructor Summary | |
|---|---|
TCPConnection(java.net.Socket aSocket)
Constructs a new TCPConnection given a Socket already connected to a remote port. |
|
TCPConnection(java.lang.String host,
int port)
Constructs a new TCPConnection given a the name of a remote host and the port number on that host with which a connection should be made. |
|
TCPConnection(java.lang.String host,
java.lang.String port)
Constructs a new TCPConnection given a the name of a remote host and the port number on that host with which a connection should be made. |
|
TCPConnection(squint.TCPSocket mySocket)
Constructs a new TCPConnection given a Socket already connected to a remote port. |
|
| Method Summary | |
|---|---|
void |
addMessageListener(TCPListener listener)
Register to be notified when new data is received through this connection and when the connection is terminated. |
void |
close()
Terminate the connection to the remote machine. |
java.lang.String |
getLocalAddress()
Returns the Internet address of this machine used for this connection |
int |
getLocalPort()
Returns the port number associated with the other end of this connection |
java.lang.String |
getRemoteAddress()
Returns the Internet address of the machine at the other end of this connection |
int |
getRemotePort()
Returns the port number associated with the other end of this connection |
void |
removeMessageListener()
Remove the listener registered for this connection |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final DataInputChannel in
public final DataOutputChannel out
| Constructor Detail |
|---|
public TCPConnection(java.lang.String host,
int port)
host - the name of the remote hostport - the number of the port to contact
public TCPConnection(java.lang.String host,
java.lang.String port)
host - the name of the remote hostport - the number of the port to contact (in String form)public TCPConnection(squint.TCPSocket mySocket)
mySocket - the TCPSocket with which TCPConnection should be associatedpublic TCPConnection(java.net.Socket aSocket)
aSocket - the Socket with which TCPConnection should be associated| Method Detail |
|---|
public void close()
public void addMessageListener(TCPListener listener)
listener - the object whose dataReceived and connectionClosed methods
should be invoked when the TCPConnection's state changespublic void removeMessageListener()
public java.lang.String getRemoteAddress()
public int getRemotePort()
public java.lang.String getLocalAddress()
public int getLocalPort()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||