net.sourceforge.jwap.wtp
Class CWTPSocket
java.lang.Object
|
+--java.lang.Thread
|
+--net.sourceforge.jwap.wtp.CWTPSocket
- All Implemented Interfaces:
- java.lang.Runnable
- public class CWTPSocket
- extends java.lang.Thread
This class interfaces to the lower layer, the UDP Layer.
We use a DatagramSocket here.
Per WSP session (defined by local port + address and remote port + address)
we need one object of type CWTPSocket. We may need more than one transaction
(CWTPTransaction) per session. CWTPSocket listens in a endless thread
for new datagrams on the DatagramSocket. If it gets one, it uses
CWTPFactory to decode the PDU. Then it associates the PDU with a transaction
by comparing the Transaction Identifier.
The constructor is private. Use #getInstance(CWTPTransaction t) to
get an object for a specific transaction. This is because we want to check,
if there already exists a CWTPManagement for the session the transaction
belongs to.
Field Summary |
static int |
DEFAULT_PORT
WAP Default client port (49200) |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
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 |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_PORT
public static final int DEFAULT_PORT
- WAP Default client port (49200)
CWTPSocket
public CWTPSocket(java.net.InetAddress toAddress,
int toPort,
IWTPUpperLayer upperLayer)
throws java.net.SocketException
CWTPSocket
public CWTPSocket(java.net.InetAddress toAddress,
int toPort,
java.net.InetAddress localAddress,
int localPort,
IWTPUpperLayer upperLayer)
throws java.net.SocketException
tr_invoke
public CWTPInitiator tr_invoke(IWTPUpperLayer upper_Layer,
CWTPEvent initPacket,
boolean ackType,
byte classType)
send
public void send(CWTPPDU pdu)
run
public void run()
- This method in an (endless) loop receives DatagramPackets (UDP)
by the DatagramSocket layer below.
Stopping: The loop can be interrupted by calling interrupt().
If you would like to stop the whole socket you better
should call close(). It also closes the DatagramSocket below.
- Overrides:
run
in class java.lang.Thread
close
public void close()
- Close the socket. Closes the underliing DatagramSocket (UDP)
addTransaction
public boolean addTransaction(IWTPTransaction t)
getTransaction
public IWTPTransaction getTransaction(int TID)
removeTransaction
public boolean removeTransaction(IWTPTransaction t)
getLocalAddress
public java.net.InetAddress getLocalAddress()
getLocalPort
public int getLocalPort()
getRemoteAddress
public java.net.InetAddress getRemoteAddress()
getRemotePort
public int getRemotePort()