|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--anthill.antnet.UdpGate
A UdpGate is an implementation of the Gate interface based on UDP. UdpGate creates a thread listening to a datagram socket, and delivers received agents to the socket it receives.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
UdpGate(int port)
Constructs a new UdpGate by instantiating a new datagram socket listening on the port contained in the anthill identifier. |
Method Summary | |
void |
clear()
Restores the object to its initial state. |
NestId |
getId()
Returns the identifier of the Nest to which this gate is associated. |
void |
run()
While-true loop waiting for a packet arriving from the datagram socket; the received packet is delivered to the agent listener object. |
void |
send(NestId id,
Ant ant,
int ttl)
Send an agent to the specified anthill. |
void |
setAntListener(AntListener listener)
Sets the ant listener, i.e. the object that will accept the ants coming from other nests. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public UdpGate(int port) throws java.io.IOException
Method Detail |
public NestId getId()
getId
in interface Gate
public void setAntListener(AntListener listener)
Gate
setAntListener
in interface Gate
anthill.nest.Gate
listener
- the listener object that will
accepts the ants coming from other nestspublic void send(NestId id, Ant ant, int ttl) throws java.io.IOException, java.lang.ClassCastException
send
in interface Gate
java.lang.ClassCastException
- raised if the anthill identifier does not belong to the
expected class (in this case, UdpNid)java.io.IOException
- raised if something goes wrong during serialization
and sendingpublic void run()
run
in class java.lang.Thread
public void clear()
Clearable
clear
in interface Clearable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |