Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

udpsock.h

Go to the documentation of this file.
00001 /*
00002  * udpsock.h
00003  *
00004  * User Datagram Protocol socket I/O channel class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: udpsock.h,v $
00030  * Revision 1.23  2003/10/27 04:06:13  csoutheren
00031  * Added code to allow compilation of new QoS code on Unix
00032  *
00033  * Revision 1.22  2003/10/27 03:22:44  csoutheren
00034  * Added handling for QoS
00035  *   Thanks to Henry Harrison of AliceStreet
00036  *
00037  * Revision 1.21  2003/09/17 05:41:59  csoutheren
00038  * Removed recursive includes
00039  *
00040  * Revision 1.20  2003/09/17 01:18:02  csoutheren
00041  * Removed recursive include file system and removed all references
00042  * to deprecated coooperative threading support
00043  *
00044  * Revision 1.19  2002/10/08 12:41:51  robertj
00045  * Changed for IPv6 support, thanks Sébastien Josset.
00046  *
00047  * Revision 1.18  2002/09/16 01:08:59  robertj
00048  * Added #define so can select if #pragma interface/implementation is used on
00049  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00050  *
00051  * Revision 1.17  2001/05/22 12:49:32  robertj
00052  * Did some seriously wierd rewrite of platform headers to eliminate the
00053  *   stupid GNU compiler warning about braces not matching.
00054  *
00055  * Revision 1.16  1999/08/27 08:18:52  robertj
00056  * Added ability to get the host/port of the the last packet read/written to UDP socket.
00057  *
00058  * Revision 1.15  1999/03/09 02:59:51  robertj
00059  * Changed comments to doc++ compatible documentation.
00060  *
00061  * Revision 1.14  1999/02/16 08:11:17  robertj
00062  * MSVC 6.0 compatibility changes.
00063  *
00064  * Revision 1.13  1998/09/23 06:21:47  robertj
00065  * Added open source copyright license.
00066  *
00067  * Revision 1.12  1997/06/06 10:54:11  craigs
00068  * Added overrides and new functions for connectionless Writes
00069  *
00070  * Revision 1.11  1996/09/14 13:09:43  robertj
00071  * Major upgrade:
00072  *   rearranged sockets to help support IPX.
00073  *   added indirect channel class and moved all protocols to descend from it,
00074  *   separating the protocol from the low level byte transport.
00075  *
00076  * Revision 1.10  1996/05/15 10:19:15  robertj
00077  * Added ICMP protocol socket, getting common ancestor to UDP.
00078  *
00079  * Revision 1.9  1996/03/03 07:38:00  robertj
00080  * Added Reusability clause to the Listen() function on sockets.
00081  *
00082  * Revision 1.8  1995/12/10 11:44:45  robertj
00083  * Numerous fixes for sockets.
00084  *
00085  * Revision 1.7  1995/06/17 11:13:41  robertj
00086  * Documentation update.
00087  *
00088  * Revision 1.6  1995/06/17 00:48:01  robertj
00089  * Implementation.
00090  *
00091  * Revision 1.5  1995/01/03 09:36:24  robertj
00092  * Documentation.
00093  *
00094  * Revision 1.4  1994/08/23  11:32:52  robertj
00095  * Oops
00096  *
00097  * Revision 1.3  1994/08/22  00:46:48  robertj
00098  * Added pragma fro GNU C++ compiler.
00099  *
00100  * Revision 1.2  1994/07/25  03:36:03  robertj
00101  * Added sockets to common, normalising to same comment standard.
00102  *
00103  */
00104 
00105 #ifndef _PUDPSOCKET
00106 #define _PUDPSOCKET
00107 
00108 #ifdef P_USE_PRAGMA
00109 #pragma interface
00110 #endif
00111 
00112 #include <ptlib/qos.h>
00113  
00117 class PUDPSocket : public PIPDatagramSocket
00118 {
00119   PCLASSINFO(PUDPSocket, PIPDatagramSocket);
00120 
00121   public:
00127     PUDPSocket(
00128       WORD port = 0             
00129     );
00130     PUDPSocket(
00131        PQoS * qos,              
00132       WORD port = 0             
00133     );
00134     PUDPSocket(
00135       const PString & service,   
00136       PQoS * qos = NULL          
00137     );
00138     PUDPSocket(
00139       const PString & address,  
00140       WORD port                 
00141     );
00142     PUDPSocket(
00143       const PString & address,  
00144       const PString & service   
00145     );
00147 
00152     BOOL Read(
00153       void * buf,   
00154       PINDEX len    
00155     );
00156 
00159     BOOL Write(
00160       const void * buf, 
00161       PINDEX len        
00162     );
00163 
00166     BOOL Connect(
00167       const PString & address   
00168     );
00170 
00175     void SetSendAddress(
00176       const Address & address,    
00177       WORD port                   
00178     );
00179 
00182     void GetSendAddress(
00183       Address & address,    
00184       WORD & port           
00185     );
00186 
00187 
00190     virtual BOOL ModifyQoSSpec(
00191       PQoS * qos            
00192     );
00193 
00198     void GetLastReceiveAddress(
00199       Address & address,    
00200       WORD & port           
00201     );
00203 
00204   protected:
00205     // Open an IPv4 socket (for backward compatibility)
00206     virtual BOOL OpenSocket();
00207 
00208     // Open an IPv4 or IPv6 socket
00209     virtual BOOL OpenSocket(
00210       int ipAdressFamily
00211     );
00212 
00213     // Create a QOS-enabled socket
00214     virtual int OpenSocketGQOS(int af, int type, int proto);
00215 
00216     // Modify the QOS settings
00217     virtual BOOL ApplyQoS();
00218 
00219     virtual const char * GetProtocolName() const;
00220 
00221     Address sendAddress;
00222     WORD    sendPort;
00223 
00224     Address lastReceiveAddress;
00225     WORD    lastReceivePort;
00226 
00227     PQoS    qosSpec;
00228 
00229 // Include platform dependent part of class
00230 #ifdef _WIN32
00231 #include "msos/ptlib/udpsock.h"
00232 #else
00233 #include "unix/ptlib/udpsock.h"
00234 #endif
00235 };
00236 
00237 #endif
00238 
00239 
00240 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 21 20:43:10 2005 for PWLib by  doxygen 1.4.1