Package org.jgroups.tests.rt.transports
Class UdpTransport
java.lang.Object
org.jgroups.tests.rt.transports.UdpTransport
- All Implemented Interfaces:
RtTransport
Transport based on UDP datagrams. Note that this transport is not reliable: if a packet is dropped, the sender will
wait for the response forever and this block.
- Since:
- 4.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InetAddressprotected final Logprotected List<SocketAddress> protected intprotected RtReceiverprotected UdpTransport.Receiverprotected booleanprotected DatagramSocket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the addresses of all cluster members.Returns the local addres of this member.String[]options()Prints the accepted options, e.g.voidSets options on this transport.voidreceiver(RtReceiver receiver) Sets the receiver whoseRtReceiver.receive(Object,byte[],int,int)callback will be invoked whenever a message is receivedvoidSends a messagevoidStarts the transport, e.g.voidstop()Stops the transport, e.g.
-
Field Details
-
sock
-
receiver_thread
-
receiver
-
host
-
port
protected int port -
server
protected boolean server -
log
-
members
-
-
Constructor Details
-
UdpTransport
public UdpTransport()
-
-
Method Details
-
options
Description copied from interface:RtTransportPrints the accepted options, e.g. [-host host] [-port port] [-server host]- Specified by:
optionsin interfaceRtTransport- Returns:
-
options
Description copied from interface:RtTransportSets options on this transport. Usually done after creation and beforeRtTransport.start(String...)is called, but may also be called at runtime.- Specified by:
optionsin interfaceRtTransport- Parameters:
options- The options- Throws:
Exception
-
receiver
Description copied from interface:RtTransportSets the receiver whoseRtReceiver.receive(Object,byte[],int,int)callback will be invoked whenever a message is received- Specified by:
receiverin interfaceRtTransport- Parameters:
receiver-
-
localAddress
Description copied from interface:RtTransportReturns the local addres of this member.- Specified by:
localAddressin interfaceRtTransport- Returns:
- The local address. Implementations without cluster membership may return null
-
clusterMembers
Description copied from interface:RtTransportReturns the addresses of all cluster members. May return null if not implemented- Specified by:
clusterMembersin interfaceRtTransport- Returns:
- The list of all members in the cluster
-
start
Description copied from interface:RtTransportStarts the transport, e.g. connecting to a server socket- Specified by:
startin interfaceRtTransport- Parameters:
options- Options passed to the transport at startup time. May be null- Throws:
Exception
-
stop
public void stop()Description copied from interface:RtTransportStops the transport, e.g. stopping the accept() loop in a TCP-based server- Specified by:
stopin interfaceRtTransport
-
send
Description copied from interface:RtTransportSends a message- Specified by:
sendin interfaceRtTransport- Parameters:
dest- The destination addressbuf- The bufferoffset- The offset at which the data startslength- The length (in bytes) of the data to send- Throws:
Exception
-