| Modifier and Type | Field and Description |
|---|---|
static int | MAX_SIZEMaximum UDP packet size. |
protected Sink | sink |
protected DatagramSocket | sock |
protected Thread | thread |
| Constructor and Description |
|---|
UDPSource(DatagramSocket sock)Creates a source using an existing socket (e.g., from UDPSink). |
UDPSource(int port)Creates a source listening on the specified port. |
| Modifier and Type | Method and Description |
|---|---|
int | getPort() |
void | run()Receives UDP datagrams in a loop and forwards them to the configured sink. |
void | setSink(Sink sink)Sets the sink for received UDP datagrams. |
void | start()Starts the source thread to begin receiving UDP datagrams. |
void | stop()Stops the source thread and closes the socket. |
public static final int MAX_SIZE
protected Sink sink
protected final DatagramSocket sock
protected final Thread thread
public UDPSource(DatagramSocket sock)
sock - the DatagramSocket to receive onpublic UDPSource(int port)
port - the local UDP port to listen onRuntimeException - if the DatagramSocket cannot be openedpublic int getPort()
public void run()
public void setSink(Sink sink)
public void start()
public void stop()