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

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1