Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvipraw.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2003 Net Integration Technologies, Inc.
00004  *
00005  */
00006 #ifndef __WVIPRAW_H
00007 #define __WVIPRAW_H
00008 
00009 #include "wvfdstream.h"
00010 #include "wvaddr.h"
00011 #include <netinet/in.h>
00012 
00013 /**
00014  * WvIPRawStream can send and receive packets on a connectionless IP socket.
00015  * 
00016  * In the constructor, the socket is attached using bind() to the given
00017  * _local address.  If the address is 0.0.0.0, all addresses on the local
00018  * host are used; if the port is 0, an available port number is chosen
00019  * automatically.
00020  * 
00021  * If the _rem address is 0.0.0.0, the port is not connect()ed.  That means
00022  * it can receive packets from anywhere and send them to anywhere.  The
00023  * src() and setdest() functions are useful for this.  If _rem is not 0.0.0.0,
00024  * connect() is called and the socket will only accept data to/from the
00025  * specified remote UDP address.
00026  * 
00027  * Buffering: all the usual WvStream-style input buffering is available,
00028  * including getline(), but because input packets may get lost it is of
00029  * limited usefulness.  Buffering will cause particular confusion if the
00030  * socket is not connect()ed.
00031  */
00032 class WvIPRawStream : public WvFDStream
00033 {
00034 public:
00035     /** connect a new socket */
00036     WvIPRawStream(const WvIPAddr &_local, const WvIPAddr &_rem,
00037                   int ip_protocol = IPPROTO_RAW);
00038     virtual ~WvIPRawStream();
00039     
00040     const WvAddr *local() const;
00041     
00042     /**
00043      * return the remote address (source of incoming packets, target of
00044      * outgoing packets).  This is the last host sent to or received from,
00045      * whichever was more recent.
00046      */
00047     virtual const WvAddr *src() const;
00048     void setdest(const WvIPAddr &_remaddr)
00049         { remaddr = _remaddr; }
00050     
00051     void enable_broadcasts();
00052 
00053 protected:
00054     WvIPAddr localaddr, remaddr;
00055     
00056     virtual size_t uread(void *buf, size_t count);
00057     virtual size_t uwrite(const void *buf, size_t count);
00058 };
00059 
00060 
00061 #endif // __WVIPRAW_H

Generated on Sat Feb 21 21:05:29 2004 for WvStreams by doxygen 1.3.5