com.cycling74.net
Class TcpSender

java.lang.Object
  extended by com.cycling74.net.TcpSender

public class TcpSender
extends java.lang.Object

TCP Sender. created on 24-May-2004


Constructor Summary
TcpSender()
          Creates a TcpSender.
TcpSender(java.lang.String address, int port)
          Creates a TcpSender with specified address and port.
 
Method Summary
 void close()
          Should be called when the TcpSender is no longer needed.
 int getActivePackets()
          Get the number of active packets.
 java.lang.String getAddress()
          Gets the IP address.
 int getPort()
          Get the port.
 void send(Atom[] a)
          Send a list.
 void send(float f)
          Send a float.
 void send(int i)
          Send an integer.
 void send(java.lang.String msg, Atom[] a)
          Send a message.
 void setAddress(java.lang.String address)
          Set the IP address.
 void setDebugString(java.lang.String debugString)
          Sets the debug String.
 void setFailureCallback(java.lang.Object toCallIn, java.lang.String methodName)
          Sets the failure callback.
 void setPort(int port)
          Set the port.
 void setSuccessCallback(java.lang.Object toCallIn, java.lang.String methodName)
          Sets the success callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpSender

public TcpSender(java.lang.String address,
                 int port)
Creates a TcpSender with specified address and port.

Parameters:
address - the address to send to
port - the port to send to

TcpSender

public TcpSender()
Creates a TcpSender. Address and port must be set before anything will work.

Method Detail

setSuccessCallback

public void setSuccessCallback(java.lang.Object toCallIn,
                               java.lang.String methodName)
Sets the success callback. The method will be called in the event of a successful data transmission. This method must take an array of Atoms as its only argument.

Parameters:
toCallIn - the object that contains the method
methodName - the name of the method

setFailureCallback

public void setFailureCallback(java.lang.Object toCallIn,
                               java.lang.String methodName)
Sets the failure callback. The method will be called in the event of a failed data transmission. This method must take an array of Atoms as its only argument.

Parameters:
toCallIn - the object that contains the method
methodName - the name of the method

setAddress

public void setAddress(java.lang.String address)
Set the IP address.

Parameters:
address - the IP address to send to

getAddress

public java.lang.String getAddress()
Gets the IP address.

Returns:
the IP address that data is being sent over

setPort

public void setPort(int port)
Set the port.

Parameters:
port - the port to send to

setDebugString

public void setDebugString(java.lang.String debugString)
Sets the debug String.

Parameters:
debugString - the String to be displayed as part of the error message in the event of a networking error.

getPort

public int getPort()
Get the port.

Returns:
the port being sent to

getActivePackets

public int getActivePackets()
Get the number of active packets. A packet is active if has been sent but it is not yet known if it was sent successfully.

Returns:
the number of active packets

send

public void send(int i)
Send an integer.

Parameters:
i - the integer to send

send

public void send(float f)
Send a float.

Parameters:
f - the float to send

send

public void send(java.lang.String msg,
                 Atom[] a)
Send a message.

Parameters:
msg - the message to send
a - arguments to the message

send

public void send(Atom[] a)
Send a list.

Parameters:
a - array of Atoms to send.

close

public void close()
Should be called when the TcpSender is no longer needed.