edu.UCL.xmiddle.controller
Class UDPSender

java.lang.Object
  |
  +--edu.UCL.xmiddle.controller.UDPSender
All Implemented Interfaces:
Sender

public class UDPSender
extends java.lang.Object
implements Sender

UDPSender.java UDPSender sends Data packets through the network to a specified UDPHost which is defined upon creation. It uses DatagramSockets (UDP) to do the sending. It also splits data to a given segment size before sending... Created: Wed Aug 1 14:18:41 2001


Constructor Summary
UDPSender(java.net.DatagramSocket socket, UDPHost host, int port)
          Creates a new UDPSender instance.
 
Method Summary
 void close()
          Closes the datagram socket.
 int getSegment()
          Returns the maximum segment size of the data.
 boolean rawSend(Data packet)
          Sends the given packet to the remote host without negotiating any packet size information
 boolean send(Data packet)
          Sends a data packet to the remote host
 void setSegment(int segment)
          Sets the maximum segment size of the data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPSender

public UDPSender(java.net.DatagramSocket socket,
                 UDPHost host,
                 int port)
Creates a new UDPSender instance.

Parameters:
socket - The datagram socket via which the data are to be sent.
host - The host to which the data are to be sent
port - the UDP port to which the packets are bound
Method Detail

close

public void close()
Closes the datagram socket.

Specified by:
close in interface Sender

getSegment

public int getSegment()
Returns the maximum segment size of the data.

Specified by:
getSegment in interface Sender
Returns:
the segment size

setSegment

public void setSegment(int segment)
Sets the maximum segment size of the data

Specified by:
setSegment in interface Sender
Parameters:
segment -

send

public boolean send(Data packet)
Sends a data packet to the remote host

Specified by:
send in interface Sender
Parameters:
packet - The data packet
Returns:
TRUE if it succedded or false otherwise

rawSend

public boolean rawSend(Data packet)
Sends the given packet to the remote host without negotiating any packet size information

Specified by:
rawSend in interface Sender
Parameters:
packet - The packet to send
Returns:
true if the packet was sent successfuly or false otherwise