|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.xmlstore.routing.messaging.MessageServer
public class MessageServer
Listens for incoming UDP messages and provides a framework for sending messages and responding to received messages. Two threads are started: One that listens for incoming messages and one that handles timeout events.
| Constructor Summary | |
|---|---|
MessageServer(int udpPort,
MessageFactory factory,
long timeout)
Constructs a MessageServer listening on the specified UDP port using the specified MessageFactory for interpreting incoming messages. |
|
| Method Summary | |
|---|---|
void |
close()
Signals to the MessageServer thread that it should stop running. |
void |
reply(int comm,
Message message,
InetAddress ip,
int port)
Sends a reply to the message with the specified communication id. |
int |
send(Message message,
InetAddress ip,
int port,
Receiver recv)
Sends the specified Message and calls the specified Receiver when a reply for the message is received. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MessageServer(int udpPort,
MessageFactory factory,
long timeout)
throws SocketException
udpPort - The UDP port on which to listen for incoming messagesfactory - Factory for creating Message and Receiver objectstimeout - The timeout period in milliseconds
SocketException - if the socket could not be opened, or the socket
could not bind to the specified local port| Method Detail |
|---|
public int send(Message message,
InetAddress ip,
int port,
Receiver recv)
throws IOException
recv is null
any reply is ignored. Returns a unique communication id which can be used
to identify a reply.
IOException
public void reply(int comm,
Message message,
InetAddress ip,
int port)
throws IOException
IOExceptionpublic void close()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||