public class UDPConnector extends Object implements Connector
Connector employing UDP as the transport protocol for exchanging
data between networked clients and a server application. It implements the
network stage in the Californium architecture.
In order to process data received from the network via UDP, client code can
register a RawDataChannel instance by means of the
setRawDataReceiver(RawDataChannel) method. Sending data out to
connected clients can be achieved by means of the send(RawData)
method.
UDP broadcast is allowed.
The number of threads can be set through setReceiverThreadCount(int)
and setSenderThreadCount(int) before the connector is started.| Modifier and Type | Field and Description |
|---|---|
static Logger |
LOGGER |
static int |
UNDEFINED |
| Constructor and Description |
|---|
UDPConnector()
Creates a connector on the wildcard address listening on an
ephemeral port, i.e.
|
UDPConnector(InetSocketAddress address)
Creates a connector bound to a given IP address and port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Stops the connector and cleans up any leftovers.
|
InetSocketAddress |
getAddress()
Gets the address of the socket this connector is bound to.
|
int |
getReceiveBufferSize() |
int |
getReceiverPacketSize() |
int |
getReceiverThreadCount() |
int |
getSendBufferSize() |
int |
getSenderThreadCount() |
void |
send(RawData msg)
Sends a raw message to a client via the network.
|
void |
setRawDataReceiver(RawDataChannel receiver)
Sets the handler for incoming messages.
|
void |
setReceiveBufferSize(int size) |
void |
setReceiverPacketSize(int size) |
void |
setReceiverThreadCount(int count) |
void |
setSendBufferSize(int size) |
void |
setSenderThreadCount(int count) |
void |
start()
Starts the connector.
|
void |
stop()
Stops the connector.
|
public static final Logger LOGGER
public static final int UNDEFINED
public UDPConnector()
UDPConnector(null).public UDPConnector(InetSocketAddress address)
address - the IP address and port, if null
the connector is bound to an ephemeral port on the wildcard addresspublic void start()
throws IOException
Connectorstart in interface ConnectorIOException - Signals that an I/O exception has occurred.public void stop()
ConnectorConnector.start() method.public void destroy()
Connectorpublic void send(RawData msg)
Connectorpublic void setRawDataReceiver(RawDataChannel receiver)
ConnectorRawDataChannel.receiveData(RawData) method
will be called whenever a new message from a client has been received
via the network.setRawDataReceiver in interface Connectorreceiver - the message handlerpublic InetSocketAddress getAddress()
ConnectorgetAddress in interface Connectorpublic void setReceiveBufferSize(int size)
public int getReceiveBufferSize()
public void setSendBufferSize(int size)
public int getSendBufferSize()
public void setReceiverThreadCount(int count)
public int getReceiverThreadCount()
public void setSenderThreadCount(int count)
public int getSenderThreadCount()
public void setReceiverPacketSize(int size)
public int getReceiverPacketSize()
Copyright © 2019 Eclipse Foundation. All rights reserved.