PTLib  Version 2.10.11
udpsock.h
Go to the documentation of this file.
1 /*
2  * udpsock.h
3  *
4  * User Datagram Protocol socket I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 26309 $
30  * $Author: ededu $
31  * $Date: 2011-08-14 18:01:01 -0500 (Sun, 14 Aug 2011) $
32  */
33 
34 #ifndef PTLIB_UDPSOCKET_H
35 #define PTLIB_UDPSOCKET_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib/ipdsock.h>
42 #include <ptlib/qos.h>
43 
48 {
49  PCLASSINFO(PUDPSocket, PIPDatagramSocket);
50 
51  public:
57  PUDPSocket(
58  WORD port = 0,
59  int iAddressFamily = AF_INET
60  );
61  PUDPSocket(
62  PQoS * qos,
63  WORD port = 0,
64  int iAddressFamily = AF_INET
65  );
66  PUDPSocket(
67  const PString & service,
68  PQoS * qos = NULL,
69  int iAddressFamily = AF_INET
70  );
71  PUDPSocket(
72  const PString & address,
73  WORD port
74  );
75  PUDPSocket(
76  const PString & address,
77  const PString & service
78  );
80 
85  PBoolean Read(
86  void * buf,
87  PINDEX len
88  );
89 
93  const void * buf,
94  PINDEX len
95  );
96 
100  const PString & address
101  );
103 
108  void SetSendAddress(
109  const Address & address,
110  WORD port
111  );
112 
115  void GetSendAddress(
116  Address & address,
117  WORD & port
118  ) const;
119  PString GetSendAddress() const;
120 
126  Address & address,
127  WORD & port
128  ) const;
130 
136  const Address & address,
137  WORD port
138  );
139 
146  virtual PBoolean DoPseudoRead(int & selectStatus);
147 
150  virtual PBoolean ModifyQoSSpec(
151  PQoS * qos
152  );
153 
154 #if P_QOS
155 
157  virtual PQoS & GetQoSSpec();
158 #endif
159 
162  static PBoolean SupportQoS(const PIPSocket::Address & address);
163 
166  static void EnableGQoS();
168 
169  protected:
170  // Open an IPv4 socket (for backward compatibility)
171  virtual PBoolean OpenSocket();
172 
173  // Open an IPv4 or IPv6 socket
174  virtual PBoolean OpenSocket(
175  int ipAdressFamily
176  );
177 
178  // Create a QOS-enabled socket
179  virtual PBoolean OpenSocketGQOS(int af, int type, int proto);
180 
181  // Modify the QOS settings
182  virtual PBoolean ApplyQoS();
183 
184  virtual const char * GetProtocolName() const;
185 
187  WORD sendPort;
188 
191 
193 
194 // Include platform dependent part of class
195 #ifdef _WIN32
196 #include "msos/ptlib/udpsock.h"
197 #else
198 #include "unix/ptlib/udpsock.h"
199 #endif
200 };
201 
202 #if P_QOS
203 
204 #ifdef _WIN32
205 #include <winbase.h>
206 #include <winreg.h>
207 
208 class PWinQoS : public PObject
209 {
210  PCLASSINFO(PWinQoS,PObject);
211 
212 public:
213  PWinQoS(PQoS & pqos, struct sockaddr * to, char * inBuf, DWORD & bufLen);
214  ~PWinQoS();
215 
216  //QOS qos;
217  //QOS_DESTADDR qosdestaddr;
218 protected:
219  sockaddr * sa;
220 };
221 
222 #endif // _WIN32
223 #endif // P_QOS
224 
225 
226 #endif // PTLIB_UDPSOCKET_H
227 
228 
229 // End Of File ///////////////////////////////////////////////////////////////
PQoS qosSpec
Definition: udpsock.h:192
WORD lastReceivePort
Definition: udpsock.h:190
Address sendAddress
Definition: udpsock.h:186
virtual PQoS & GetQoSSpec()
Get the QOS object for the socket.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:47
virtual PBoolean OpenSocket()
WORD port
Port to be used by the socket when opening the channel.
Definition: socket.h:444
PBoolean Connect(const PString &address)
Override of PSocket functions to allow connectionless writes.
virtual PBoolean ApplyQoS()
PUDPSocket(WORD port=0, int iAddressFamily=AF_INET)
Create a UDP socket.
BOOL PBoolean
Definition: object.h:102
WORD sendPort
Definition: udpsock.h:187
Definition: qos.h:67
PBoolean Read(void *buf, PINDEX len)
Override of PChannel functions to allow connectionless reads.
PBoolean Write(const void *buf, PINDEX len)
Override of PChannel functions to allow connectionless writes.
virtual PBoolean IsAlternateAddress(const Address &address, WORD port)
CallBack to check if the detected address of the connectionless Read() is an alternate address...
virtual PBoolean DoPseudoRead(int &selectStatus)
PseudoRead This indicates to the upper system that reading on this socket will be a pseudo read when ...
PString GetSendAddress() const
void SetSendAddress(const Address &address, WORD port)
Set the address to use for connectionless Write() or Windows QoS.
The character string class.
Definition: pstring.h:108
Address lastReceiveAddress
Definition: udpsock.h:189
static void EnableGQoS()
Manually Enable GQoS Support.
virtual PBoolean OpenSocketGQOS(int af, int type, int proto)
static PBoolean SupportQoS(const PIPSocket::Address &address)
Check to See if the socket will support QoS on the given local Address.
A class describing an IP address.
Definition: ipsock.h:75
PString GetLastReceiveAddress() const
Internet Protocol Datagram Socket class.
Definition: ipdsock.h:45
virtual const char * GetProtocolName() const
This function returns the protocol name for the socket type.
virtual PBoolean ModifyQoSSpec(PQoS *qos)
Change the QOS spec for the socket and try to apply the changes.
Ultimate parent class for all objects in the class library.
Definition: object.h:1118