|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmil.navy.nps.dis.BehaviorStreamBuffer
mil.navy.nps.dis.BehaviorStreamBufferUDP
BehaviorStreamBufferUDP is responsible for reading from the network, specifically from packet-oriented (UDP and multicast) sockets. it is a subclass of the abstract class BehaviorStreamBuffer.
In general, this should be run via a thread--create a thread with an instance of this class in it, and run the thread. This will prevent blocking IO on the socket from stopping the application.
Field Summary | |
protected DatagramStreamBuffer |
datagramStreamBuffer
|
Fields inherited from class mil.navy.nps.dis.BehaviorStreamBuffer |
DEBUG, info, inputThreadStarted, readThreadRunning, rtpEnabled, runContinue, strategy |
Constructor Summary | |
BehaviorStreamBufferUDP()
A constructor that creates a new unicast socket datagramStreamBuffer on an ephemeral (system-chosen) port. |
|
BehaviorStreamBufferUDP(DatagramStreamBuffer pDatagramStreamBuffer)
Creates a BehaviorStreamBufferNetwork with the specified DatagramStream. |
|
BehaviorStreamBufferUDP(int pDatagramPort)
A constructor that creates a new unicast socket. |
|
BehaviorStreamBufferUDP(java.lang.String pMulticastAddress,
int pDatagramPort)
A constructor that creates a multicast socket datagramStreamBuffer If the netscape security classes are visible, this instantiates itself as a netscape-specific datagramStreamBuffer, able to bypass the Java sandbox. |
Method Summary | |
void |
cleanup()
Closes down sockets nicely |
protected void |
finalize()
Finalize method--used to clean up any sockets that are still open |
java.net.InetAddress |
getAddress()
Accessor method to provide current multicast address. |
ProtocolDataUnit |
getNextPdu()
Get the next PDU from the input stream. |
int |
getPort()
Accessor method to provide current multicast port. |
java.util.Vector |
receivedPdus()
Returns a vector of all the PDUs received since the last time we asked. |
void |
resumeReading()
Start reading packets from the datagramStreamBuffer again. |
void |
run()
Threading method to read/write via datagramStreamBuffer until shutdown. |
void |
sendDatagram(java.net.InetAddress pDestHost,
int pPort,
java.lang.String pCommand)
|
void |
sendPdu(ProtocolDataUnit pPdu)
Sends a PDU. |
void |
sendPdu(ProtocolDataUnit pPdu,
java.lang.Object pAddress1,
java.lang.Object pAddress2)
Send a PDU to an address. |
void |
sendPdu(ProtocolDataUnit pdu,
java.lang.String pDestinationHost,
int pDestinationPort)
|
void |
sendPduMulticast(ProtocolDataUnit pPdu)
|
void |
setTimeToLive(int pTTL)
JDK 1.2 version: set the multicast socket time-to-live, with 15=> local distribution, 63=>regional distribution, 127=>global distribution. |
void |
setTTL(byte pTTL)
(Deprecated) JDK 1.1 version: set the multicast socket time-to-live, with 15=> local distribution, 63=>regional distribution, 127=>global distribution. |
void |
shutdown()
Terminate the run loop and shutdown the thread. |
void |
startInputThread()
Simple method to launch thread because Microsoft puts security restraints on everything. |
void |
suspendReading()
suspend reading in the DatagramStreamBuffer |
Methods inherited from class mil.navy.nps.dis.BehaviorStreamBuffer |
checkForThreadStart, debug, getDEBUG, getInfo, getRtpEnabled, sendPdu, setDEBUG, setInfo, setRtpEnabled, startInputThreadWithSecurity, trace |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected DatagramStreamBuffer datagramStreamBuffer
Constructor Detail |
public BehaviorStreamBufferUDP(int pDatagramPort)
pDatagramPort
- the port we read from on this sidepublic BehaviorStreamBufferUDP()
If the Netscape security classes are visible, this instantiates itself with an underlying Netscape-specific DatagramStreamBuffer. Otherwise, it uses an generic, security-free datagramStreamBuffer. This also starts a thread responsible for reading from the socket.
public BehaviorStreamBufferUDP(java.lang.String pMulticastAddress, int pDatagramPort)
Note that this creates a thread to read from the socket.
public BehaviorStreamBufferUDP(DatagramStreamBuffer pDatagramStreamBuffer)
Method Detail |
public void startInputThread()
EntityDispatcher is static; only one copy is shared between all instances of the EspduTransform and other Script nodes. If it's null the first time through here, create and thread it.
This is synchronized, since we may have N EspduTransforms attempting to instantiate themselves at once, all accessing this shared class variable. The synchronization prevents multiple access.
This is actually some magic code. Java keeps several mutex locks around, one for every instance of a class and one for the class itself. We can't sychronize on entityDispatcher because that's null the first time through, which will fail silently. We also can't use a java primitive type. So I created a completely arbitrary instance of an object as a class variable, and synchronize on that. It's a standin for the EntityDispatcher in a way. When done, it starts reading from the input socket.
startInputThread
in class BehaviorStreamBuffer
public void shutdown()
shutdown
in class BehaviorStreamBuffer
public java.net.InetAddress getAddress()
public int getPort()
public void run()
run
in interface java.lang.Runnable
run
in class BehaviorStreamBuffer
public java.util.Vector receivedPdus()
receivedPdus
in class BehaviorStreamBuffer
public ProtocolDataUnit getNextPdu()
BehaviorStreamBuffer
getNextPdu
in class BehaviorStreamBuffer
public void setTimeToLive(int pTTL)
Note that browsers are still using JDK 1.1 while command-line applications can use JDK 1.2.
see java.net.MulticastSocket.setTTL()
public void setTTL(byte pTTL)
see java.net.MulticastSocket.setTimeToLive()
public void sendPdu(ProtocolDataUnit pPdu)
sendPdu
in class BehaviorStreamBuffer
public void sendPdu(ProtocolDataUnit pPdu, java.lang.Object pAddress1, java.lang.Object pAddress2)
sendPdu
in class BehaviorStreamBuffer
pPdu
- protocol data unit being sentpAddress1
- the first part of the address, typically the inet addresspAddress2
- the second part of the address, typically null or the destiation portpublic void sendPduMulticast(ProtocolDataUnit pPdu)
public void sendPdu(ProtocolDataUnit pdu, java.lang.String pDestinationHost, int pDestinationPort)
public void sendDatagram(java.net.InetAddress pDestHost, int pPort, java.lang.String pCommand)
public void suspendReading()
suspendReading
in class BehaviorStreamBuffer
public void resumeReading()
resumeReading
in class BehaviorStreamBuffer
public void cleanup()
cleanup
in class BehaviorStreamBuffer
protected void finalize() throws java.lang.Throwable
finalize
in class BehaviorStreamBuffer
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |