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  * $Revision: 19008 $
00030  * $Author: rjongbloed $
00031  * $Date: 2007-11-29 09:17:41 +0000 (Thu, 29 Nov 2007) $
00032  */
00033 
00034 #ifndef _PUDPSOCKET
00035 #define _PUDPSOCKET
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 #include <ptlib/qos.h>
00042  
00046 class PUDPSocket : public PIPDatagramSocket
00047 {
00048   PCLASSINFO(PUDPSocket, PIPDatagramSocket);
00049 
00050   public:
00056     PUDPSocket(
00057       WORD port = 0             
00058     );
00059     PUDPSocket(
00060        PQoS * qos,              
00061       WORD port = 0             
00062     );
00063     PUDPSocket(
00064       const PString & service,   
00065       PQoS * qos = NULL          
00066     );
00067     PUDPSocket(
00068       const PString & address,  
00069       WORD port                 
00070     );
00071     PUDPSocket(
00072       const PString & address,  
00073       const PString & service   
00074     );
00076 
00081     PBoolean Read(
00082       void * buf,   
00083       PINDEX len    
00084     );
00085 
00088     PBoolean Write(
00089       const void * buf, 
00090       PINDEX len        
00091     );
00092 
00095     PBoolean Connect(
00096       const PString & address   
00097     );
00099 
00104     void SetSendAddress(
00105       const Address & address,    
00106       WORD port                   
00107     );
00108 
00111     void GetSendAddress(
00112       Address & address,    
00113       WORD & port           
00114     );
00115 
00116 
00119     virtual PBoolean ModifyQoSSpec(
00120       PQoS * qos            
00121     );
00122 
00123 #if P_HAS_QOS
00124 
00126     virtual PQoS & GetQoSSpec();
00127 #endif
00128 
00132     void GetLastReceiveAddress(
00133       Address & address,    
00134       WORD & port           
00135     );
00136 
00139     static PBoolean SupportQoS(const PIPSocket::Address & address);
00140 
00143     static void EnableGQoS();
00145 
00146   protected:
00147     // Open an IPv4 socket (for backward compatibility)
00148     virtual PBoolean OpenSocket();
00149 
00150     // Open an IPv4 or IPv6 socket
00151     virtual PBoolean OpenSocket(
00152       int ipAdressFamily
00153     );
00154 
00155     // Create a QOS-enabled socket
00156     virtual PBoolean OpenSocketGQOS(int af, int type, int proto);
00157 
00158     // Modify the QOS settings
00159     virtual PBoolean ApplyQoS();
00160 
00161     virtual const char * GetProtocolName() const;
00162 
00163     Address sendAddress;
00164     WORD    sendPort;
00165 
00166     Address lastReceiveAddress;
00167     WORD    lastReceivePort;
00168 
00169     PQoS    qosSpec;
00170 
00171 // Include platform dependent part of class
00172 #ifdef _WIN32
00173 #include "msos/ptlib/udpsock.h"
00174 #else
00175 #include "unix/ptlib/udpsock.h"
00176 #endif
00177 };
00178 
00179 #if P_HAS_QOS
00180 
00181 #ifdef _WIN32
00182 #include <winbase.h>
00183 #include <winreg.h>
00184 
00185 #ifndef _WIN32_WCE
00186 
00187 class PWinQoS : public PObject
00188 {
00189     PCLASSINFO(PWinQoS,PObject);
00190 
00191 public:
00192     PWinQoS(PQoS & pqos, struct sockaddr * to, char * inBuf, DWORD & bufLen);
00193     ~PWinQoS();
00194     
00195     //QOS qos;
00196     //QOS_DESTADDR qosdestaddr;
00197 protected:
00198     sockaddr * sa;
00199 };
00200 
00201 #endif  // _WIN32_WCE
00202 #endif  // _WIN32
00203 #endif // P_HAS_QOS
00204 
00205 
00206 #endif
00207 
00208 
00209 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Dec 10 11:18:57 2007 for PTLib by  doxygen 1.5.1