|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.ic.doc.automed.p2p.communication.AbstractClient
uk.ac.ic.doc.automed.p2p.communication.UDPClient
public class UDPClient
Field Summary | |
---|---|
private java.net.DatagramSocket |
_clientSocket
|
private byte[] |
_dataReceived
|
private static boolean |
debugError
|
Fields inherited from class uk.ac.ic.doc.automed.p2p.communication.AbstractClient |
---|
ackExpected, dataToSend, handler, isReady, props, serverHostName, serverPort |
Constructor Summary | |
---|---|
UDPClient(RequestListener handler)
|
|
UDPClient(java.lang.String serverHostName,
int serverPort,
RequestListener handler,
byte[] dataToSend,
java.util.Properties props)
Creates a new instance of UDPClient |
|
UDPClient(java.lang.String serverHostName,
int serverPort,
RequestListener handler,
java.util.Properties props)
Creates a new instance of UDPClient |
Method Summary | |
---|---|
private static int |
getFragmentSize(byte[] dataBuffer)
|
byte[] |
getReceivedData()
Get the data received from server |
void |
handleAction()
Handle thread's interrupted action |
static java.net.DatagramPacket |
receiveDatagram(java.net.DatagramSocket socket)
Receive response packets in a separate thread |
void |
runAction()
Implement UDP communication process |
static void |
sendDatagram(java.net.DatagramSocket dsock,
byte[] dataToSend,
java.net.InetAddress remoteAddress,
int remotePort)
An utility method for sending a datagram given a socket. |
Methods inherited from class uk.ac.ic.doc.automed.p2p.communication.AbstractClient |
---|
getHandlerObject, getReadyState, setDataToSend, setReadyState |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.net.DatagramSocket _clientSocket
private byte[] _dataReceived
private static final boolean debugError
Constructor Detail |
---|
public UDPClient(java.lang.String serverHostName, int serverPort, RequestListener handler, byte[] dataToSend, java.util.Properties props)
serverHostName
- host name of the UDP serverserverPort
- UDP port on serverhandler
- an RequestListener
object for processing messagesdataToSend
- in array of bytespublic UDPClient(RequestListener handler)
public UDPClient(java.lang.String serverHostName, int serverPort, RequestListener handler, java.util.Properties props)
serverHostName
- host name of the UDP serverserverPort
- UDP port on serverMethod Detail |
---|
public void runAction() throws AutoMedException
runAction
in interface Threadable
runAction
in class AbstractClient
AutoMedException
public static java.net.DatagramPacket receiveDatagram(java.net.DatagramSocket socket) throws CommunicationException
CommunicationException
public void handleAction()
handleAction
in interface Threadable
handleAction
in class AbstractClient
public byte[] getReceivedData()
public static void sendDatagram(java.net.DatagramSocket dsock, byte[] dataToSend, java.net.InetAddress remoteAddress, int remotePort) throws CommunicationException
AppConstants.PACKET_SIZE
as needed.
CommunicationException
private static int getFragmentSize(byte[] dataBuffer)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |