Class UdpMessenger
java.lang.Object
java.lang.Thread
org.sentrysoftware.ipmi.core.transport.UdpMessenger
Handles the UDP connection.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionUdpMessenger
(int port) Initiates UdpMessenger, binds it to the specified port and starts listening.UdpMessenger
(int port, InetAddress address) Initiates UdpMessenger, binds it to the specified port and IP address and starts listening. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the socket and releases port.int
int
getPort()
static int
Returns number of packets sent since last creation of the instance ofUdpMessenger
.void
register
(UdpListener listener) Registers listener in the UdpMessenger so it will be notified viaUdpListener.notifyMessage(UdpMessage)
when new message arrives.void
run()
void
send
(UdpMessage message) SendsUdpMessage
.void
setBufferSize
(int bufferSize) Sets message data buffer size to bufferSize.void
unregister
(UdpListener listener) Unregisters listener from UdpMessenger so it no longer will be notified.Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
Constructor Details
-
UdpMessenger
Initiates UdpMessenger, binds it to the specified port and starts listening. Wildcard IP address will be used.- Parameters:
port
- - port to bind socket to.- Throws:
SocketException
- if the socket could not be opened, or the socket could not bind to the specified local port.UnknownHostException
-
UdpMessenger
Initiates UdpMessenger, binds it to the specified port and IP address and starts listening.- Parameters:
port
- - port to bind socket to.address
- - IP address to bind socket to.- Throws:
SocketException
- if the socket could not be opened, or the socket could not bind to the specified local port.
-
-
Method Details
-
getPort
public int getPort() -
setBufferSize
public void setBufferSize(int bufferSize) Sets message data buffer size to bufferSize. -
getBufferSize
public int getBufferSize()- Returns:
- Size of the message data buffer
-
run
public void run() -
closeConnection
public void closeConnection()Closes the socket and releases port.- Specified by:
closeConnection
in interfaceMessenger
-
register
Registers listener in the UdpMessenger so it will be notified viaUdpListener.notifyMessage(UdpMessage)
when new message arrives.- Specified by:
register
in interfaceMessenger
- Parameters:
listener
- -UdpListener
to register.
-
unregister
Unregisters listener from UdpMessenger so it no longer will be notified.- Specified by:
unregister
in interfaceMessenger
- Parameters:
listener
- -UdpListener
to unregister
-
getSentPackets
public static int getSentPackets()Returns number of packets sent since last creation of the instance ofUdpMessenger
. For debug/testing purposes only. -
send
SendsUdpMessage
.- Specified by:
send
in interfaceMessenger
- Parameters:
message
- -UdpMessage
to send.- Throws:
IOException
- when sending of the message fails
-