Class Poco::Net::UDPClient (original) (raw)

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

Description

UDP client can either send, or send/receive UDP packets. The mode of operation is specified at construction time. If receiving functionality is enabled, it will run in a separate thread. This class is written as a "companion" to Poco::Net::UDPServer. For other servers, inherit from this class and override the handleResponse(char*, int) virtual member.

Inheritance

Direct Base Classes: Poco::Runnable

All Base Classes: Poco::Runnable

Member Summary

Member Functions: address, dataBacklog, errorBacklog, getOption, handleResponse, peerAddress, run, send, setOption, stop

Inherited Functions: run

Constructors

UDPClient

UDPClient(
const std::string & address,
Poco::UInt16 port,
bool listen = false
);

Creates UDP client and connects it to specified address/port. If listen is true, a thread is launched where client can receive responses rom the server.

Destructor

~UDPClient virtual

virtual ~UDPClient();

Member Functions

address inline

SocketAddress address() const;

Returns client address.

dataBacklog inline

int dataBacklog() const;

Returns current server data backlog.

errorBacklog inline

int errorBacklog();

Returns current server error backlog.

getOption inline

int getOption(
int opt
);

Returns socket option.

handleResponse virtual

virtual int handleResponse(
char * buffer,
int length
);

Handles responses from UDP server. For non-POCO UDP servers, this function should be overridden in inheriting class.

peerAddress inline

SocketAddress peerAddress() const;

Returns server address.

run virtual

void run();

Runs listener (typically invoked internally, in separate thread).

send inline

int send(
void * data,
int length
);

Sends data.

send

int send(
const SocketBufVec & vec
);

Sends data.

setOption inline

void setOption(
int opt,
int val
);

Sets socket option.

stop inline

void stop();

Stops the server reply receiving thread, if running.