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: 26309 $
00030  * $Author: ededu $
00031  * $Date: 2011-08-14 18:01:01 -0500 (Sun, 14 Aug 2011) $
00032  */
00033 
00034 #ifndef PTLIB_UDPSOCKET_H
00035 #define PTLIB_UDPSOCKET_H
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       int iAddressFamily = AF_INET 
00060     );
00061     PUDPSocket(
00062        PQoS * qos,              
00063       WORD port = 0,            
00064       int iAddressFamily = AF_INET 
00065     );
00066     PUDPSocket(
00067       const PString & service,   
00068       PQoS * qos = NULL,         
00069       int iAddressFamily = AF_INET 
00070     );
00071     PUDPSocket(
00072       const PString & address,  
00073       WORD port                 
00074     );
00075     PUDPSocket(
00076       const PString & address,  
00077       const PString & service   
00078     );
00080 
00085     PBoolean Read(
00086       void * buf,   
00087       PINDEX len    
00088     );
00089 
00092     PBoolean Write(
00093       const void * buf, 
00094       PINDEX len        
00095     );
00096 
00099     PBoolean Connect(
00100       const PString & address   
00101     );
00103 
00108     void SetSendAddress(
00109       const Address & address,    
00110       WORD port                   
00111     );
00112 
00115     void GetSendAddress(
00116       Address & address,    
00117       WORD & port           
00118     ) const;
00119     PString GetSendAddress() const;
00120 
00125     void GetLastReceiveAddress(
00126       Address & address,    
00127       WORD & port           
00128     ) const;
00129     PString GetLastReceiveAddress() const;
00130 
00135     virtual PBoolean IsAlternateAddress(
00136       const Address & address,    
00137       WORD port                    
00138     );
00139 
00146     virtual PBoolean DoPseudoRead(int & selectStatus);
00147 
00150     virtual PBoolean ModifyQoSSpec(
00151       PQoS * qos            
00152     );
00153 
00154 #if P_QOS
00155 
00157     virtual PQoS & GetQoSSpec();
00158 #endif
00159 
00162     static PBoolean SupportQoS(const PIPSocket::Address & address);
00163 
00166     static void EnableGQoS();
00168 
00169   protected:
00170     // Open an IPv4 socket (for backward compatibility)
00171     virtual PBoolean OpenSocket();
00172 
00173     // Open an IPv4 or IPv6 socket
00174     virtual PBoolean OpenSocket(
00175       int ipAdressFamily
00176     );
00177 
00178     // Create a QOS-enabled socket
00179     virtual PBoolean OpenSocketGQOS(int af, int type, int proto);
00180 
00181     // Modify the QOS settings
00182     virtual PBoolean ApplyQoS();
00183 
00184     virtual const char * GetProtocolName() const;
00185 
00186     Address sendAddress;
00187     WORD    sendPort;
00188 
00189     Address lastReceiveAddress;
00190     WORD    lastReceivePort;
00191 
00192     PQoS    qosSpec;
00193 
00194 // Include platform dependent part of class
00195 #ifdef _WIN32
00196 #include "msos/ptlib/udpsock.h"
00197 #else
00198 #include "unix/ptlib/udpsock.h"
00199 #endif
00200 };
00201 
00202 #if P_QOS
00203 
00204 #ifdef _WIN32
00205 #include <winbase.h>
00206 #include <winreg.h>
00207 
00208 class PWinQoS : public PObject
00209 {
00210     PCLASSINFO(PWinQoS,PObject);
00211 
00212 public:
00213     PWinQoS(PQoS & pqos, struct sockaddr * to, char * inBuf, DWORD & bufLen);
00214     ~PWinQoS();
00215     
00216     //QOS qos;
00217     //QOS_DESTADDR qosdestaddr;
00218 protected:
00219     sockaddr * sa;
00220 };
00221 
00222 #endif  // _WIN32
00223 #endif // P_QOS
00224 
00225 
00226 #endif // PTLIB_UDPSOCKET_H
00227 
00228 
00229 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Feb 15 20:58:32 2013 for PTLib by  doxygen 1.4.7