9 #include "wvistreamlist.h"
13 int main(
int argc,
char **argv)
15 WvLog err(
"udp", WvLog::Error);
17 WvIPPortAddr remaddr(argc > 1 ? argv[1] :
"127.0.0.1:19");
20 sock.enable_broadcasts();
22 err(WvLog::Info,
"Local address is %s.\n", *sock.local());
25 sock.autoforward(err);
28 l.add_after(l.tail, wvcon,
false);
29 l.add_after(l.tail, &sock,
false);
31 while (wvcon->
isok() && sock.isok())
33 sock.setdest(remaddr);
38 else if (sock.select(0))
41 err(WvLog::Info,
" (remote: %s)\n", *sock.src());
47 err(
"stdin: %s\n", strerror(wvcon->
geterr()));
48 else if (!sock.isok() && sock.geterr())
49 err(
"socket: %s\n", strerror(sock.geterr()));
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
virtual void callback()
if the stream has a callback function defined, call it now.
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
An IP+Port address also includes a port number, with the resulting form www.xxx.yyy....
void autoforward(WvStream &s)
set the callback function for this stream to an internal routine that auto-forwards all incoming stre...
virtual bool isok() const
return true if the stream is actually usable right now
WvUDPStream can send and receive packets on a connectionless UDP socket.
WvStreamList holds a list of WvStream objects – and its select() and callback() functions know how to...