network
Class SocketComms

java.lang.Object
  extended by network.AbCommsTCP
      extended by network.SocketComms
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class SocketComms
extends AbCommsTCP
implements java.lang.Runnable, java.io.Serializable

Created on November 5, 2006, 9:14 AM
Handles communications when sending data to a remote host.

Extends AbCommsTCP, sends the data packet in a loop until the loop is terminated.
The communication loop is terminated either by the object using SocketComms, such as when an ack is received, or if no ack is required.
t.5 Changes from using datagrampackets to using a bufferedInputStream from a socket connection.

Version:
t.5
Author:
Eric Angeli
See Also:
Serialized Form

Constructor Summary
SocketComms()
          Creates a new instance of SocketComms
 
Method Summary
 void run()
          Handles running the thread.
 void sendSocket()
          Sends the data buffer to the remote host.
 void setTheSocket(java.net.InetAddress theAddress, int port)
          Creates a new socket for connecting.
 void stopComms()
          Stops comms.
Calls the super.stopComms in AbComms and tries to close the output stream.
 
Methods inherited from class network.AbCommsTCP
addPropertyChangeListener, getBuffer, getConnectedAddress, getPort, getPropertySupport, getRemoteHost, getRunner, getSocket, isAckRequired, isAlreadyConnected, isPauseComms, isRunning, removePropertyChangeListener, setAckRequired, setAlreadyConnected, setBuffer, setConnectedAddress, setPauseComms, setPort, setRemoteHost, setRunner, setRunning, setSocket, startComms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketComms

public SocketComms()
Creates a new instance of SocketComms

Method Detail

setTheSocket

public void setTheSocket(java.net.InetAddress theAddress,
                         int port)
Creates a new socket for connecting.

Parameters:
theAddress - The address of the remote host to connect to.
port - The port on the remote host to connect to.

sendSocket

public void sendSocket()
Sends the data buffer to the remote host.


run

public void run()
Handles running the thread.
Contains the communications loop.
Loops until terminated.
In the case of SocketComms, this will loop until the owner recieves an ack and terminates the thread, or if no ack is required.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class AbCommsTCP

stopComms

public void stopComms()
Stops comms.
Calls the super.stopComms in AbComms and tries to close the output stream.

Overrides:
stopComms in class AbCommsTCP