# Poco::Net

# template < std::size_t S = POCO_UDP_BUF_SIZE >

# class UDPSocketReader

Library: Net
Package: UDP
Header: Poco/Net/UDPSocketReader.h

## Description

UDPSocketReader is responsible for UDP socket I/O operations. When data or error is detected on a socket, the reader is invoked to do the I/O. After the data is read, it is passed on, to one of the handlers for processing. Errors are also passed to a handler for handling (if any configured). Depending on settings, data senders may be notified of the handler's data and error backlogs.

## Member Summary

Member Functions: handlerDone, handlerStopped, read, setError, stopHandler

## Constructors

### UDPSocketReader

UDPSocketReader(
typename UDPHandlerImpl < S >::List & handlers,
int backlogThreshold = 0
);

Creates the UDPSocketReader.

### UDPSocketReader

UDPSocketReader(
typename UDPHandlerImpl < S >::List & handlers,
const UDPServerParams & serverParams
);

Creates the UDPSocketReader.

## Destructor

### ~UDPSocketReader

~UDPSocketReader();

Destroys the UDPSocketReader.

## Member Functions

### handlerDone

bool handlerDone() const;

Returns true if all handlers are done processing data.

### handlerStopped

bool handlerStopped() const;

Returns true if all handlers are stopped.

### read

void read(
DatagramSocket & sock
);

Reads data from the socket and passes it to the next handler. Errors are also passed to the handler. If object is configured for replying to sender and data or error backlog threshold is exceeded, sender is notified of the current backlog size.

### setError

AtomicCounter::ValueType setError(
int sock,
char * buf = 0,
const std::string & err = ""
);

Sets error to the provided buffer buf. If the buffer is null, a new buffer is obtained from handler. If successful, returns the handler's eror backlog size, otherwise returns zero.

### stopHandler

void stopHandler();

Stops all handlers.