All Packages Class Hierarchy This Package Previous Next Index
Class reliability.SAWSender
java.lang.Object
|
+----timer.TimerClient
|
+----reliability.SAWSender
- public class SAWSender
- extends TimerClient
- implements ReliableSender, PacketReceiver
Implementation of a stop-and-wait sender
Provided implementation shows stop-and-wait protocol,
plus all the general setup and use of the SendBuffer
This implementation uses both the SendBuffer and
NetworkInterface classes. You are not required to use
these, but they simplify interaction with the timer and
the underlying network. If you want to modify or replace
them, be sure to understand them first.
-
SAWSender(Network, Address)
- Create a new stop-and-wait sender.
-
Close()
- Close the current connection.
-
Open(Address)
- Open a connection to the ReliableReceiver represented by
the address.
-
PacketArrived(NetworkPacket)
- Processing that happens when we receive a packet
For stop-and-wait: send the next packet
-
Send(byte[])
- Send a block of data on the connection.
-
Timeout(Object)
- Processing that happens when we get a timeout
For stop-and-wait: resend the current packet
SAWSender
public SAWSender(Network network,
Address address)
- Create a new stop-and-wait sender.
- Parameters:
- network - the network to communicate on
- address - the address of this host
Open
public void Open(Address destination)
- Open a connection to the ReliableReceiver represented by
the address. This call blocks until the connection is
established.
For stop-and-wait, true connection setup is not implemented,
and this jsut sets the destination
- Parameters:
- destination - the address of the receiver
Send
public void Send(byte data[]) throws ConnectionNotOpenException
- Send a block of data on the connection. Any amount of
data may be sent. This call may block if there is
insufficient buffer space. Clients may make any number
of Send calls per open connection.
- Parameters:
- data - the data (any amount) to send on the connection
Close
public void Close() throws ConnectionNotOpenException
- Close the current connection. Blocks until all data
is read by the other application and the close
operation completes.
PacketArrived
public void PacketArrived(NetworkPacket pk)
- Processing that happens when we receive a packet
For stop-and-wait: send the next packet
Timeout
public void Timeout(Object info)
- Processing that happens when we get a timeout
For stop-and-wait: resend the current packet
- Overrides:
- Timeout in class TimerClient
All Packages Class Hierarchy This Package Previous Next Index