udpsock.h
Go to the documentation of this file.
/*
* udpsock.h
*
* User Datagram Protocol socket I/O channel class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 26309 $
* $Author: ededu $
* $Date: 2011-08-14 18:01:01 -0500 (Sun, 14 Aug 2011) $
*/
#ifndef PTLIB_UDPSOCKET_H
#define PTLIB_UDPSOCKET_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib/ipdsock.h>
#include <ptlib/qos.h>
class PUDPSocket : public PIPDatagramSocket
{
PCLASSINFO(PUDPSocket, PIPDatagramSocket);
public:
PUDPSocket(
WORD port = 0,
int iAddressFamily = AF_INET
);
PUDPSocket(
PQoS * qos,
WORD port = 0,
int iAddressFamily = AF_INET
);
PUDPSocket(
const PString & service,
PQoS * qos = NULL,
int iAddressFamily = AF_INET
);
PUDPSocket(
const PString & address,
WORD port
);
PUDPSocket(
const PString & address,
const PString & service
);
PBoolean Read(
void * buf,
PINDEX len
);
PBoolean Write(
const void * buf,
PINDEX len
);
PBoolean Connect(
const PString & address
);
void SetSendAddress(
const Address & address,
WORD port
);
void GetSendAddress(
Address & address,
WORD & port
) const;
PString GetSendAddress() const;
void GetLastReceiveAddress(
Address & address,
WORD & port
) const;
PString GetLastReceiveAddress() const;
virtual PBoolean IsAlternateAddress(
const Address & address,
WORD port
);
virtual PBoolean DoPseudoRead(int & selectStatus);
virtual PBoolean ModifyQoSSpec(
PQoS * qos
);
#if P_QOS
virtual PQoS & GetQoSSpec();
#endif
static PBoolean SupportQoS(const PIPSocket::Address & address);
static void EnableGQoS();
protected:
// Open an IPv4 socket (for backward compatibility)
virtual PBoolean OpenSocket();
// Open an IPv4 or IPv6 socket
virtual PBoolean OpenSocket(
int ipAdressFamily
);
// Create a QOS-enabled socket
virtual PBoolean OpenSocketGQOS(int af, int type, int proto);
// Modify the QOS settings
virtual PBoolean ApplyQoS();
virtual const char * GetProtocolName() const;
Address sendAddress;
WORD sendPort;
Address lastReceiveAddress;
WORD lastReceivePort;
PQoS qosSpec;
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/udpsock.h"
#else
#include "unix/ptlib/udpsock.h"
#endif
};
#if P_QOS
#ifdef _WIN32
#include <winbase.h>
#include <winreg.h>
class PWinQoS : public PObject
{
PCLASSINFO(PWinQoS,PObject);
public:
PWinQoS(PQoS & pqos, struct sockaddr * to, char * inBuf, DWORD & bufLen);
~PWinQoS();
//QOS qos;
//QOS_DESTADDR qosdestaddr;
protected:
sockaddr * sa;
};
#endif // _WIN32
#endif // P_QOS
#endif // PTLIB_UDPSOCKET_H
// End Of File ///////////////////////////////////////////////////////////////
PUDPSocket::qosSpec
PQoS qosSpec
Definition: udpsock.h:192
PUDPSocket::lastReceivePort
WORD lastReceivePort
Definition: udpsock.h:190
PUDPSocket::sendAddress
Address sendAddress
Definition: udpsock.h:186
PUDPSocket::GetQoSSpec
virtual PQoS & GetQoSSpec()
Get the QOS object for the socket.
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PUDPSocket::GetSendAddress
PString GetSendAddress() const
PUDPSocket
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:47
qos.h
PUDPSocket::OpenSocket
virtual PBoolean OpenSocket()
ipdsock.h
PSocket::port
WORD port
Port to be used by the socket when opening the channel.
Definition: socket.h:444
PUDPSocket::Connect
PBoolean Connect(const PString &address)
Override of PSocket functions to allow connectionless writes.
PUDPSocket::ApplyQoS
virtual PBoolean ApplyQoS()
PUDPSocket::PUDPSocket
PUDPSocket(WORD port=0, int iAddressFamily=AF_INET)
Create a UDP socket.
PBoolean
BOOL PBoolean
Definition: object.h:102
PUDPSocket::sendPort
WORD sendPort
Definition: udpsock.h:187
PQoS
Definition: qos.h:67
PUDPSocket::Read
PBoolean Read(void *buf, PINDEX len)
Override of PChannel functions to allow connectionless reads.
PUDPSocket::Write
PBoolean Write(const void *buf, PINDEX len)
Override of PChannel functions to allow connectionless writes.
PUDPSocket::GetProtocolName
virtual const char * GetProtocolName() const
This function returns the protocol name for the socket type.
PUDPSocket::IsAlternateAddress
virtual PBoolean IsAlternateAddress(const Address &address, WORD port)
CallBack to check if the detected address of the connectionless Read() is an alternate address...
PUDPSocket::GetLastReceiveAddress
PString GetLastReceiveAddress() const
PUDPSocket::DoPseudoRead
virtual PBoolean DoPseudoRead(int &selectStatus)
PseudoRead This indicates to the upper system that reading on this socket will be a pseudo read when ...
PUDPSocket::SetSendAddress
void SetSendAddress(const Address &address, WORD port)
Set the address to use for connectionless Write() or Windows QoS.
PString
The character string class.
Definition: pstring.h:108
PUDPSocket::lastReceiveAddress
Address lastReceiveAddress
Definition: udpsock.h:189
PUDPSocket::EnableGQoS
static void EnableGQoS()
Manually Enable GQoS Support.
PUDPSocket::OpenSocketGQOS
virtual PBoolean OpenSocketGQOS(int af, int type, int proto)
PUDPSocket::SupportQoS
static PBoolean SupportQoS(const PIPSocket::Address &address)
Check to See if the socket will support QoS on the given local Address.
PIPSocket::Address
A class describing an IP address.
Definition: ipsock.h:75
PIPDatagramSocket
Internet Protocol Datagram Socket class.
Definition: ipdsock.h:45
PUDPSocket::ModifyQoSSpec
virtual PBoolean ModifyQoSSpec(PQoS *qos)
Change the QOS spec for the socket and try to apply the changes.
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118